Struct spinners::Spinner

source ·
pub struct Spinner { /* private fields */ }

Implementations§

source§

impl Spinner

source

pub fn new(spinner: Spinners, message: String) -> Self

Create a new spinner along with a message

Examples

Basic Usage:

use spinners::{Spinner, Spinners};

let sp = Spinner::new(Spinners::Dots, "Loading things into memory...".into());

No Message:

use spinners::{Spinner, Spinners};

let sp = Spinner::new(Spinners::Dots, String::new());
source

pub fn with_timer(spinner: Spinners, message: String) -> Self

Create a new spinner that logs the time since it was created

source

pub fn with_stream(spinner: Spinners, message: String, stream: Stream) -> Self

Creates a new spinner along with a message with a specified output stream

Examples

Basic Usage:

use spinners::{Spinner, Spinners, Stream};
 
let sp = Spinner::with_stream(Spinners::Dots, String::new(), Stream::Stderr);
source

pub fn with_timer_and_stream( spinner: Spinners, message: String, stream: Stream ) -> Self

Creates a new spinner that logs the time since it was created with a specified output stream

Examples

Basic Usage:

use spinners::{Spinner, Spinners, Stream};
 
let sp = Spinner::with_timer_and_stream(Spinners::Dots, String::new(), Stream::Stderr);
source

pub fn stop(&mut self)

Stops the spinner

Stops the spinner that was created with the Spinner::new function.

Optionally call stop_with_newline to print a newline after the spinner is stopped, or the stop_with_message function to print a message after the spinner is stopped.

Examples

Basic Usage:

use spinners::{Spinner, Spinners};

let mut sp = Spinner::new(Spinners::Dots, "Loading things into memory...".into());

sp.stop();
source

pub fn stop_with_symbol(&mut self, symbol: &str)

Stop with a symbol that replaces the spinner

The symbol is a String rather than a Char to allow for more flexibility, such as using ANSI color codes.

Examples

Basic Usage:

use spinners::{Spinner, Spinners};

let mut sp = Spinner::new(Spinners::Dots, "Loading things into memory...".into());

sp.stop_with_symbol("🗸");

ANSI colors (green checkmark):

use spinners::{Spinner, Spinners};

let mut sp = Spinner::new(Spinners::Dots, "Loading things into memory...".into());

sp.stop_with_symbol("\x1b[32m🗸\x1b[0m");
source

pub fn stop_with_newline(&mut self)

Stops the spinner and prints a new line

Examples

Basic Usage:

use spinners::{Spinner, Spinners};

let mut sp = Spinner::new(Spinners::Dots, "Loading things into memory...".into());

sp.stop_with_newline();
source

pub fn stop_with_message(&mut self, msg: String)

Stops the spinner and prints the provided message

Examples

Basic Usage:

use spinners::{Spinner, Spinners};

let mut sp = Spinner::new(Spinners::Dots, "Loading things into memory...".into());

sp.stop_with_message("Finished loading things into memory!".into());
source

pub fn stop_and_persist(&mut self, symbol: &str, msg: String)

Stops the spinner with a provided symbol and message

Examples

Basic Usage:

use spinners::{Spinner, Spinners};

let mut sp = Spinner::new(Spinners::Dots, "Loading things into memory...".into());

sp.stop_and_persist("✔", "Finished loading things into memory!".into());

Trait Implementations§

source§

impl Drop for Spinner

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.