aboutsummaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-14 11:35:05 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-14 11:35:05 +0200
commit01a2737bd8537da41a3babdd2b0949795492a59e (patch)
tree095b9151b7fbfae87412643bb4e6ec9b76ac32c3 /src/util.rs
parentbaa714538d14cb3eb7d29468962946059b4318fd (diff)
downloadnetapp-01a2737bd8537da41a3babdd2b0949795492a59e.tar.gz
netapp-01a2737bd8537da41a3babdd2b0949795492a59e.zip
Document
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs
index a87f779..bf8f4cb 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -4,6 +4,7 @@ use log::info;
use tokio::sync::watch;
+/// A node's identifier, which is also its public cryptographic key
pub type NodeID = sodiumoxide::crypto::sign::ed25519::PublicKey;
/// Utility function: encodes any serializable value in MessagePack binary format
@@ -25,6 +26,7 @@ where
/// This async function returns only when a true signal was received
/// from a watcher that tells us when to exit.
+///
/// Usefull in a select statement to interrupt another
/// future:
/// ```ignore
@@ -41,6 +43,8 @@ pub async fn await_exit(mut must_exit: watch::Receiver<bool>) {
}
}
+/// Creates a watch that contains `false`, and that changes
+/// to `true` when a Ctrl+C signal is received.
pub fn watch_ctrl_c() -> watch::Receiver<bool> {
let (send_cancel, watch_cancel) = watch::channel(false);
tokio::spawn(async move {