pub struct Spinner { /* private fields */ }Expand description
Spinner for indeterminate operations with unknown duration.
Automatically suppressed in non-TTY, JSON mode, or quiet mode. When suppressed, all operations become no-ops.
§Examples
use sublime_cli_tools::output::progress::Spinner;
let spinner = Spinner::new("Loading...");
// ... do work ...
spinner.finish_with_message("✓ Done");Implementations§
Source§impl Spinner
impl Spinner
Sourcepub fn new(msg: impl Into<String>) -> Self
pub fn new(msg: impl Into<String>) -> Self
Creates a new spinner with the given message.
The spinner is automatically suppressed if:
- stdout is not a TTY
- Output format is JSON or quiet
§Examples
use sublime_cli_tools::output::progress::Spinner;
let spinner = Spinner::new("Loading packages...");Sourcepub fn new_with_format(msg: impl Into<String>, format: OutputFormat) -> Self
pub fn new_with_format(msg: impl Into<String>, format: OutputFormat) -> Self
Creates a new spinner with explicit format control.
§Examples
use sublime_cli_tools::output::{progress::Spinner, OutputFormat};
let spinner = Spinner::new_with_format("Loading...", OutputFormat::Human);Sourcepub fn set_message(&self, msg: impl Into<String>)
pub fn set_message(&self, msg: impl Into<String>)
Sets the spinner message.
§Examples
use sublime_cli_tools::output::progress::Spinner;
let spinner = Spinner::new("Loading...");
spinner.set_message("Still loading...");Sourcepub fn tick(&self)
pub fn tick(&self)
Manually ticks the spinner (usually not needed due to steady tick).
§Examples
use sublime_cli_tools::output::progress::Spinner;
let spinner = Spinner::new("Loading...");
spinner.tick();Sourcepub fn finish(&self)
pub fn finish(&self)
Finishes the spinner and clears it.
§Examples
use sublime_cli_tools::output::progress::Spinner;
let spinner = Spinner::new("Loading...");
spinner.finish();Sourcepub fn finish_with_message(&self, msg: impl Into<String>)
pub fn finish_with_message(&self, msg: impl Into<String>)
Finishes the spinner with a message.
§Examples
use sublime_cli_tools::output::progress::Spinner;
let spinner = Spinner::new("Loading...");
spinner.finish_with_message("✓ Loaded 5 packages");Sourcepub fn abandon(&self)
pub fn abandon(&self)
Finishes the spinner and abandons it (shows as incomplete).
§Examples
use sublime_cli_tools::output::progress::Spinner;
let spinner = Spinner::new("Loading...");
spinner.abandon();Sourcepub fn abandon_with_message(&self, msg: impl Into<String>)
pub fn abandon_with_message(&self, msg: impl Into<String>)
Finishes the spinner and abandons it with a message.
§Examples
use sublime_cli_tools::output::progress::Spinner;
let spinner = Spinner::new("Loading...");
spinner.abandon_with_message("✗ Failed to load");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
Mutably borrows from an owned value. Read more