Skip to main content

Spinner

Struct Spinner 

Source
pub struct Spinner { /* private fields */ }

Implementations§

Source§

impl Spinner

Source

pub fn new(text: impl Into<String>) -> Self

Examples found in repository?
examples/basic.rs (line 6)
5fn main() -> io::Result<()> {
6    let mut spinner = Spinner::new("Preparing workspace");
7
8    spinner.start()?;
9    thread::sleep(Duration::from_millis(800));
10
11    spinner.set_text("Fetching dependencies");
12    thread::sleep(Duration::from_millis(800));
13
14    spinner.set_text("Running checks");
15    thread::sleep(Duration::from_millis(800));
16
17    spinner.succeed(Some("Workspace ready"))?;
18    Ok(())
19}
Source

pub fn builder() -> SpinnerBuilder

Examples found in repository?
examples/custom_style.rs (line 6)
5fn main() -> io::Result<()> {
6    let mut spinner = Spinner::builder()
7        .text("Processing build graph")
8        .prefix_text("pipeline")
9        .suffix_text("phase-1")
10        .color(Color::Yellow)
11        .spinner(SpinnerStyle::arrow())
12        .indent(4)
13        .stream(Stream::Stderr)
14        .build();
15
16    spinner.start()?;
17    thread::sleep(Duration::from_millis(900));
18
19    spinner.set_suffix_text("phase-2");
20    spinner.set_text("Packing release artifacts");
21    thread::sleep(Duration::from_millis(900));
22
23    spinner.set_color(Some(Color::Green));
24    spinner.succeed(Some("Release artifacts ready"))?;
25    Ok(())
26}
Source

pub fn with_options(options: SpinnerOptions) -> Self

Source

pub fn start(&mut self) -> Result<&mut Self>

Examples found in repository?
examples/basic.rs (line 8)
5fn main() -> io::Result<()> {
6    let mut spinner = Spinner::new("Preparing workspace");
7
8    spinner.start()?;
9    thread::sleep(Duration::from_millis(800));
10
11    spinner.set_text("Fetching dependencies");
12    thread::sleep(Duration::from_millis(800));
13
14    spinner.set_text("Running checks");
15    thread::sleep(Duration::from_millis(800));
16
17    spinner.succeed(Some("Workspace ready"))?;
18    Ok(())
19}
More examples
Hide additional examples
examples/custom_style.rs (line 16)
5fn main() -> io::Result<()> {
6    let mut spinner = Spinner::builder()
7        .text("Processing build graph")
8        .prefix_text("pipeline")
9        .suffix_text("phase-1")
10        .color(Color::Yellow)
11        .spinner(SpinnerStyle::arrow())
12        .indent(4)
13        .stream(Stream::Stderr)
14        .build();
15
16    spinner.start()?;
17    thread::sleep(Duration::from_millis(900));
18
19    spinner.set_suffix_text("phase-2");
20    spinner.set_text("Packing release artifacts");
21    thread::sleep(Duration::from_millis(900));
22
23    spinner.set_color(Some(Color::Green));
24    spinner.succeed(Some("Release artifacts ready"))?;
25    Ok(())
26}
Source

pub fn stop(&mut self) -> Result<&mut Self>

Source

pub fn clear(&mut self) -> Result<&mut Self>

Source

pub fn stop_and_persist<T>( &mut self, symbol: impl Into<String>, text: Option<T>, ) -> Result<&mut Self>
where T: Into<String>,

Source

pub fn succeed<T>(&mut self, text: Option<T>) -> Result<&mut Self>
where T: Into<String>,

Examples found in repository?
examples/basic.rs (line 17)
5fn main() -> io::Result<()> {
6    let mut spinner = Spinner::new("Preparing workspace");
7
8    spinner.start()?;
9    thread::sleep(Duration::from_millis(800));
10
11    spinner.set_text("Fetching dependencies");
12    thread::sleep(Duration::from_millis(800));
13
14    spinner.set_text("Running checks");
15    thread::sleep(Duration::from_millis(800));
16
17    spinner.succeed(Some("Workspace ready"))?;
18    Ok(())
19}
More examples
Hide additional examples
examples/custom_style.rs (line 24)
5fn main() -> io::Result<()> {
6    let mut spinner = Spinner::builder()
7        .text("Processing build graph")
8        .prefix_text("pipeline")
9        .suffix_text("phase-1")
10        .color(Color::Yellow)
11        .spinner(SpinnerStyle::arrow())
12        .indent(4)
13        .stream(Stream::Stderr)
14        .build();
15
16    spinner.start()?;
17    thread::sleep(Duration::from_millis(900));
18
19    spinner.set_suffix_text("phase-2");
20    spinner.set_text("Packing release artifacts");
21    thread::sleep(Duration::from_millis(900));
22
23    spinner.set_color(Some(Color::Green));
24    spinner.succeed(Some("Release artifacts ready"))?;
25    Ok(())
26}
Source

pub fn fail<T>(&mut self, text: Option<T>) -> Result<&mut Self>
where T: Into<String>,

Source

pub fn warn<T>(&mut self, text: Option<T>) -> Result<&mut Self>
where T: Into<String>,

Source

pub fn info<T>(&mut self, text: Option<T>) -> Result<&mut Self>
where T: Into<String>,

Source

pub fn text(&self) -> String

Source

pub fn set_text(&mut self, text: impl Into<String>) -> &mut Self

Examples found in repository?
examples/basic.rs (line 11)
5fn main() -> io::Result<()> {
6    let mut spinner = Spinner::new("Preparing workspace");
7
8    spinner.start()?;
9    thread::sleep(Duration::from_millis(800));
10
11    spinner.set_text("Fetching dependencies");
12    thread::sleep(Duration::from_millis(800));
13
14    spinner.set_text("Running checks");
15    thread::sleep(Duration::from_millis(800));
16
17    spinner.succeed(Some("Workspace ready"))?;
18    Ok(())
19}
More examples
Hide additional examples
examples/custom_style.rs (line 20)
5fn main() -> io::Result<()> {
6    let mut spinner = Spinner::builder()
7        .text("Processing build graph")
8        .prefix_text("pipeline")
9        .suffix_text("phase-1")
10        .color(Color::Yellow)
11        .spinner(SpinnerStyle::arrow())
12        .indent(4)
13        .stream(Stream::Stderr)
14        .build();
15
16    spinner.start()?;
17    thread::sleep(Duration::from_millis(900));
18
19    spinner.set_suffix_text("phase-2");
20    spinner.set_text("Packing release artifacts");
21    thread::sleep(Duration::from_millis(900));
22
23    spinner.set_color(Some(Color::Green));
24    spinner.succeed(Some("Release artifacts ready"))?;
25    Ok(())
26}
Source

pub fn set_prefix_text(&mut self, text: impl Into<String>) -> &mut Self

Source

pub fn set_suffix_text(&mut self, text: impl Into<String>) -> &mut Self

Examples found in repository?
examples/custom_style.rs (line 19)
5fn main() -> io::Result<()> {
6    let mut spinner = Spinner::builder()
7        .text("Processing build graph")
8        .prefix_text("pipeline")
9        .suffix_text("phase-1")
10        .color(Color::Yellow)
11        .spinner(SpinnerStyle::arrow())
12        .indent(4)
13        .stream(Stream::Stderr)
14        .build();
15
16    spinner.start()?;
17    thread::sleep(Duration::from_millis(900));
18
19    spinner.set_suffix_text("phase-2");
20    spinner.set_text("Packing release artifacts");
21    thread::sleep(Duration::from_millis(900));
22
23    spinner.set_color(Some(Color::Green));
24    spinner.succeed(Some("Release artifacts ready"))?;
25    Ok(())
26}
Source

pub fn set_color(&mut self, color: Option<Color>) -> &mut Self

Examples found in repository?
examples/custom_style.rs (line 23)
5fn main() -> io::Result<()> {
6    let mut spinner = Spinner::builder()
7        .text("Processing build graph")
8        .prefix_text("pipeline")
9        .suffix_text("phase-1")
10        .color(Color::Yellow)
11        .spinner(SpinnerStyle::arrow())
12        .indent(4)
13        .stream(Stream::Stderr)
14        .build();
15
16    spinner.start()?;
17    thread::sleep(Duration::from_millis(900));
18
19    spinner.set_suffix_text("phase-2");
20    spinner.set_text("Packing release artifacts");
21    thread::sleep(Duration::from_millis(900));
22
23    spinner.set_color(Some(Color::Green));
24    spinner.succeed(Some("Release artifacts ready"))?;
25    Ok(())
26}
Source

pub fn set_spinner(&mut self, spinner: SpinnerStyle) -> &mut Self

Source

pub fn snapshot(&self) -> SpinnerSnapshot

Source

pub fn is_spinning(&self) -> bool

Trait Implementations§

Source§

impl Drop for Spinner

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.