pub struct Spinner { /* private fields */ }Expand description
A simple terminal spinner that runs in a background thread
The spinner automatically stops and cleans up when dropped, making it safe to use in code paths that may error or panic.
§Example
use cascade_cli::utils::spinner::Spinner;
let mut spinner = Spinner::new("Loading data".to_string());
// ... do some work ...
spinner.stop_with_message("✓ Data loaded");Implementations§
Source§impl Spinner
impl Spinner
Sourcepub fn new(message: String) -> Self
pub fn new(message: String) -> Self
Start a new spinner with the given message
The spinner will animate in a background thread until stopped.
Sourcepub fn new_with_output_below(message: String) -> Self
pub fn new_with_output_below(message: String) -> Self
Start a new spinner that stays on one line while content appears below
This variant prints the message with a newline, then updates only the spinner character using ANSI cursor positioning. Content can be printed below without being overwritten by the spinner.
Sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Stop the spinner and clear the line
This method is idempotent - it’s safe to call multiple times.
Sourcepub fn stop_with_message(&mut self, message: &str)
pub fn stop_with_message(&mut self, message: &str)
Stop the spinner and replace with a final message
This is useful for showing success/failure status after completion.
Sourcepub fn update_message(&mut self, new_message: String)
pub fn update_message(&mut self, new_message: String)
Update the spinner’s message while it’s running
Note: This creates a brief flicker as we stop and restart the spinner. For frequent updates, consider using stop_with_message() instead.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Spinner
impl !RefUnwindSafe for Spinner
impl Send for Spinner
impl Sync for Spinner
impl Unpin for Spinner
impl !UnwindSafe for Spinner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more