summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Nguyen <benjamin.van.nguyen@gmail.com>2023-07-01 10:40:12 +0700
committerBenjamin Nguyen <benjamin.van.nguyen@gmail.com>2023-07-01 10:40:12 +0700
commita0e5a7702e63a80745efb81137bc7b28d8a8faa3 (patch)
tree9e074bfbb09f6da8bca1555657f9269b0c26f17e
parenta9f90f0bf281f0661d25fdc7a5039095e984a186 (diff)
add missing doc comments
-rw-r--r--src/progress.rs5
-rw-r--r--src/tty/mod.rs4
2 files changed, 8 insertions, 1 deletions
diff --git a/src/progress.rs b/src/progress.rs
index 9acc332..87395f9 100644
--- a/src/progress.rs
+++ b/src/progress.rs
@@ -13,6 +13,7 @@ use std::{
time::Duration,
};
+/// Timeout used for [`IndicatorHandle`]'s `priority_mailbox`.
const PRIORITY_MAIL_TIMEOUT: Duration = Duration::from_nanos(1);
/// Responsible for displying the progress indicator. This struct will be owned by a separate
@@ -27,6 +28,9 @@ pub struct Indicator<'a> {
/// This struct is how the outside world will inform the [`Indicator`] about the progress of the
/// program. The `join_handle` returns the handle to the thread that owns the [`Indicator`] and the
/// `mailbox` is the [`SyncSender`] channel that allows [`Message`]s to be sent to [`Indicator`].
+///
+/// The `priority_mailbox` is used to prematurely terminate the [`Indicator`] in the case of say a
+/// `SIGINT` signal.
pub struct IndicatorHandle {
pub join_handle: Option<JoinHandle<Result<(), Error>>>,
mailbox: SyncSender<Message>,
@@ -107,6 +111,7 @@ impl IndicatorHandle {
self.priority_mailbox.clone()
}
+ /// Send a message through to the `priority_mailbox` tear down the [`Indicator`].
pub fn terminate(this: Option<Arc<Self>>) -> Result<(), Error> {
if let Some(mut handle) = this {
handle.priority_mailbox().send(())?;
diff --git a/src/tty/mod.rs b/src/tty/mod.rs
index b11da25..f5cd922 100644
--- a/src/tty/mod.rs
+++ b/src/tty/mod.rs
@@ -21,7 +21,9 @@ pub fn stdout_is_tty() -> bool {
/// Restore terminal settings.
pub fn restore_tty() {
- stdout().execute(cursor::Show).expect("Failed to restore cursor");
+ stdout()
+ .execute(cursor::Show)
+ .expect("Failed to restore cursor");
}
/// Attempts to get the current size of the tty's window. Returns `None` if stdout isn't tty or if