Struct conciliator::spin::Spinner
source · pub struct Spinner<'c> { /* private fields */ }
Expand description
Show that something is ongoing with an animated tag & message
This starts a separate thread (or task) that periodically overwrites the last line of the output to show the next frame of the animation.
Any other output would interfere with this, so this struct tries to guard against that by holding a mutable reference to the Claw
that spawned it.
This ensures that that particular Claw
can’t be used for the lifetime of the Spinner
.
See the module-level documentation for more.
Implementations§
source§impl<'c> Spinner<'c>
impl<'c> Spinner<'c>
sourcepub fn new<A, I>(claw: &'c mut Claw, animate: A, message: I) -> Self
pub fn new<A, I>(claw: &'c mut Claw, animate: A, message: I) -> Self
Create a new Spinner
using the given animation and message
sourcepub fn message<I: InitialContent>(&self, init: I) -> Message<'_> ⓘ
pub fn message<I: InitialContent>(&self, init: I) -> Message<'_> ⓘ
Update the spinner message
The message should be short enough to fit on a single line in the terminal, and it should not contain any newlines. If the message line wraps to another line, the spinner will get messed up and leave behind lines that it shouldn’t.
sourcepub async fn finish(self)
Available on crate feature tokio
only.
pub async fn finish(self)
tokio
only.Stop spinning
This changes the animation frame to show the spinner is done and un-hides the cursor.
The last message
set will be written out and become part of the normal output.
Note that without the tokio
feature, this function is not async
.