pub struct AnimatedSpinner { /* private fields */ }Expand description
Animated spinner for indeterminate progress.
Displays an animated spinner with a message and elapsed time. Thread-safe and uses RAII for clean terminal state on drop.
§Features
- Automatic rate limiting (10 FPS / 100ms per frame)
- Multiple animation styles
- Elapsed time display
- Success/failure/skipped final states
- Transition to progress bar when total becomes known
§Example
let mut spinner = AnimatedSpinner::new(ctx, "Connecting to worker...");
// Animate while working...
for _ in 0..100 {
spinner.tick(); // Call periodically to animate
std::thread::sleep(std::time::Duration::from_millis(50));
}
// When done:
spinner.finish_success("Connected!");Implementations§
Source§impl AnimatedSpinner
impl AnimatedSpinner
Sourcepub fn new(ctx: OutputContext, message: impl Into<String>) -> Self
pub fn new(ctx: OutputContext, message: impl Into<String>) -> Self
Create a new animated spinner.
Sourcepub fn with_style(
ctx: OutputContext,
message: impl Into<String>,
style: SpinnerStyle,
) -> Self
pub fn with_style( ctx: OutputContext, message: impl Into<String>, style: SpinnerStyle, ) -> Self
Create a spinner with a specific animation style.
Sourcepub fn nested(&self, message: impl Into<String>) -> Self
pub fn nested(&self, message: impl Into<String>) -> Self
Create a nested spinner that shares animation state with parent.
Nested spinners synchronize their animation frames for visual coherence.
Sourcepub fn set_message(&mut self, message: impl Into<String>)
pub fn set_message(&mut self, message: impl Into<String>)
Set the spinner message.
Sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Update the spinner animation.
Call this periodically while the operation is in progress. Rate-limited to 10 FPS automatically.
Sourcepub fn set_total(&mut self, total: u64)
pub fn set_total(&mut self, total: u64)
Transition the spinner to a progress bar.
When the total count becomes known, the spinner transforms into a determinate progress bar.
Sourcepub fn set_progress(&mut self, current: u64)
pub fn set_progress(&mut self, current: u64)
Update progress when in progress bar mode.
Sourcepub fn finish_success(&mut self, message: impl Into<String>)
pub fn finish_success(&mut self, message: impl Into<String>)
Finish with success state.
Sourcepub fn finish_error(&mut self, message: impl Into<String>)
pub fn finish_error(&mut self, message: impl Into<String>)
Finish with error state.
Sourcepub fn finish_skipped(&mut self, message: impl Into<String>)
pub fn finish_skipped(&mut self, message: impl Into<String>)
Finish with skipped state.
Sourcepub fn finish_with(&mut self, result: SpinnerResult, message: impl Into<String>)
pub fn finish_with(&mut self, result: SpinnerResult, message: impl Into<String>)
Finish with a specific result state.