pub struct Spinner { /* private fields */ }
Implementations§
source§impl Spinner
impl Spinner
sourcepub fn new(spinner: Spinners, message: String) -> Self
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());
sourcepub fn with_timer(spinner: Spinners, message: String) -> Self
pub fn with_timer(spinner: Spinners, message: String) -> Self
Create a new spinner that logs the time since it was created
sourcepub fn with_stream(spinner: Spinners, message: String, stream: Stream) -> Self
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);
sourcepub fn with_timer_and_stream(
spinner: Spinners,
message: String,
stream: Stream,
) -> Self
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);
sourcepub fn stop(&mut self)
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();
sourcepub fn stop_with_symbol(&mut self, symbol: &str)
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");
sourcepub fn stop_with_newline(&mut self)
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();
sourcepub fn stop_with_message(&mut self, msg: String)
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());
sourcepub fn stop_and_persist(&mut self, symbol: &str, msg: String)
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());