pub struct Spinner<S> { /* private fields */ }Expand description
A Spinach spinner
Represents a spinner that can be used to show progress or activity.
§Examples
use spinach::Spinner;
let spinner = Spinner::new("Loading...").start();
// Perform some tasks
spinner.text("gg!").success();Implementations§
Source§impl<S> Spinner<S>
impl<S> Spinner<S>
Sourcepub fn color(&self, color: Color) -> &Self
pub fn color(&self, color: Color) -> &Self
Sets the color of the spinner.
§Examples
use spinach::{Spinner, Color};
let spinner = Spinner::new("workin'...").color(Color::Blue).start();Examples found in repository?
examples/cooking.rs (line 9)
7fn main() {
8 let spinner = Spinner::new("Cutting spinaches")
9 .color(Green)
10 .frames_duration(30)
11 .start();
12
13 sleep(Duration::from_secs(1));
14 spinner.text("Cutting tomatoes").update();
15
16 sleep(Duration::from_secs(1));
17 spinner.text("Vegetables cut").symbol("🔪").stop();
18
19 let spinner = Spinner::new("Cooking vegetables")
20 .color(Green)
21 .frames_duration(30)
22 .start();
23
24 sleep(Duration::from_secs(1));
25 spinner.text("Vegetables cooked").symbol("🍲").stop();
26
27 sleep(Duration::from_secs(1));
28}Sourcepub fn text(&self, text: &str) -> &Self
pub fn text(&self, text: &str) -> &Self
Sets the text displayed alongside the spinner.
§Examples
use spinach::Spinner;
let spinner = Spinner::new("workin'...").start();Examples found in repository?
examples/cooking.rs (line 14)
7fn main() {
8 let spinner = Spinner::new("Cutting spinaches")
9 .color(Green)
10 .frames_duration(30)
11 .start();
12
13 sleep(Duration::from_secs(1));
14 spinner.text("Cutting tomatoes").update();
15
16 sleep(Duration::from_secs(1));
17 spinner.text("Vegetables cut").symbol("🔪").stop();
18
19 let spinner = Spinner::new("Cooking vegetables")
20 .color(Green)
21 .frames_duration(30)
22 .start();
23
24 sleep(Duration::from_secs(1));
25 spinner.text("Vegetables cooked").symbol("🍲").stop();
26
27 sleep(Duration::from_secs(1));
28}Sourcepub fn symbols(&self, symbols: Vec<&'static str>) -> &Self
pub fn symbols(&self, symbols: Vec<&'static str>) -> &Self
Sets the symbols used for the spinner animation.
§Examples
use spinach::Spinner;
let spinner = Spinner::new("workin'...").symbols(vec!["◐", "◓", "◑", "◒"]).start();Sourcepub fn symbol(&self, symbol: &'static str) -> &Self
pub fn symbol(&self, symbol: &'static str) -> &Self
Sets a single symbol for the spinner animation. This is useful when you want to set a final symbol, for example.
§Examples
use spinach::Spinner;
let spinner = Spinner::new("workin'...").start().text("done!").symbol("✔").stop();Examples found in repository?
examples/cooking.rs (line 17)
7fn main() {
8 let spinner = Spinner::new("Cutting spinaches")
9 .color(Green)
10 .frames_duration(30)
11 .start();
12
13 sleep(Duration::from_secs(1));
14 spinner.text("Cutting tomatoes").update();
15
16 sleep(Duration::from_secs(1));
17 spinner.text("Vegetables cut").symbol("🔪").stop();
18
19 let spinner = Spinner::new("Cooking vegetables")
20 .color(Green)
21 .frames_duration(30)
22 .start();
23
24 sleep(Duration::from_secs(1));
25 spinner.text("Vegetables cooked").symbol("🍲").stop();
26
27 sleep(Duration::from_secs(1));
28}Sourcepub fn frames_duration(&self, ms: u64) -> &Self
pub fn frames_duration(&self, ms: u64) -> &Self
Sets the duration of each frame in the spinner animation.
§Examples
use spinach::Spinner;
let spinner = Spinner::new("workin'...").frames_duration(40).start();Examples found in repository?
examples/cooking.rs (line 10)
7fn main() {
8 let spinner = Spinner::new("Cutting spinaches")
9 .color(Green)
10 .frames_duration(30)
11 .start();
12
13 sleep(Duration::from_secs(1));
14 spinner.text("Cutting tomatoes").update();
15
16 sleep(Duration::from_secs(1));
17 spinner.text("Vegetables cut").symbol("🔪").stop();
18
19 let spinner = Spinner::new("Cooking vegetables")
20 .color(Green)
21 .frames_duration(30)
22 .start();
23
24 sleep(Duration::from_secs(1));
25 spinner.text("Vegetables cooked").symbol("🍲").stop();
26
27 sleep(Duration::from_secs(1));
28}Source§impl Spinner<Stopped>
impl Spinner<Stopped>
Sourcepub fn new(text: &str) -> Self
pub fn new(text: &str) -> Self
Creates a new spinner.
§Examples
use spinach::Spinner;
let spinner = Spinner::new("let's go...").start();Examples found in repository?
examples/cooking.rs (line 8)
7fn main() {
8 let spinner = Spinner::new("Cutting spinaches")
9 .color(Green)
10 .frames_duration(30)
11 .start();
12
13 sleep(Duration::from_secs(1));
14 spinner.text("Cutting tomatoes").update();
15
16 sleep(Duration::from_secs(1));
17 spinner.text("Vegetables cut").symbol("🔪").stop();
18
19 let spinner = Spinner::new("Cooking vegetables")
20 .color(Green)
21 .frames_duration(30)
22 .start();
23
24 sleep(Duration::from_secs(1));
25 spinner.text("Vegetables cooked").symbol("🍲").stop();
26
27 sleep(Duration::from_secs(1));
28}Sourcepub fn start(&self) -> Spinner<Running>
pub fn start(&self) -> Spinner<Running>
Starts the spinner.
§Examples
use spinach::Spinner;
let spinner = Spinner::new("let's go...").start();Examples found in repository?
examples/cooking.rs (line 11)
7fn main() {
8 let spinner = Spinner::new("Cutting spinaches")
9 .color(Green)
10 .frames_duration(30)
11 .start();
12
13 sleep(Duration::from_secs(1));
14 spinner.text("Cutting tomatoes").update();
15
16 sleep(Duration::from_secs(1));
17 spinner.text("Vegetables cut").symbol("🔪").stop();
18
19 let spinner = Spinner::new("Cooking vegetables")
20 .color(Green)
21 .frames_duration(30)
22 .start();
23
24 sleep(Duration::from_secs(1));
25 spinner.text("Vegetables cooked").symbol("🍲").stop();
26
27 sleep(Duration::from_secs(1));
28}Source§impl Spinner<Running>
impl Spinner<Running>
Sourcepub fn update(&self) -> &Self
pub fn update(&self) -> &Self
Updates the spinner with the current update state.
§Examples
use spinach::Spinner;
let spinner = Spinner::new("Doing something...").start();
// Perform some tasks
spinner.text("Doing something else...").update();Examples found in repository?
examples/cooking.rs (line 14)
7fn main() {
8 let spinner = Spinner::new("Cutting spinaches")
9 .color(Green)
10 .frames_duration(30)
11 .start();
12
13 sleep(Duration::from_secs(1));
14 spinner.text("Cutting tomatoes").update();
15
16 sleep(Duration::from_secs(1));
17 spinner.text("Vegetables cut").symbol("🔪").stop();
18
19 let spinner = Spinner::new("Cooking vegetables")
20 .color(Green)
21 .frames_duration(30)
22 .start();
23
24 sleep(Duration::from_secs(1));
25 spinner.text("Vegetables cooked").symbol("🍲").stop();
26
27 sleep(Duration::from_secs(1));
28}Sourcepub fn stop(&self)
pub fn stop(&self)
Stops the spinner.
§Examples
use spinach::Spinner;
let spinner = Spinner::new("Doing something...").start();
// Perform some tasks
spinner.text("done!").stop();Examples found in repository?
examples/cooking.rs (line 17)
7fn main() {
8 let spinner = Spinner::new("Cutting spinaches")
9 .color(Green)
10 .frames_duration(30)
11 .start();
12
13 sleep(Duration::from_secs(1));
14 spinner.text("Cutting tomatoes").update();
15
16 sleep(Duration::from_secs(1));
17 spinner.text("Vegetables cut").symbol("🔪").stop();
18
19 let spinner = Spinner::new("Cooking vegetables")
20 .color(Green)
21 .frames_duration(30)
22 .start();
23
24 sleep(Duration::from_secs(1));
25 spinner.text("Vegetables cooked").symbol("🍲").stop();
26
27 sleep(Duration::from_secs(1));
28}Sourcepub fn success(&self)
pub fn success(&self)
Stops the spinner with a pre-configured success indication. Sets the symbol and color.
§Examples
use spinach::Spinner;
let spinner = Spinner::new("Doing something...").start();
// Perform some task that succeeds
spinner.text("done!").success();Trait Implementations§
Auto Trait Implementations§
impl<S> !Freeze for Spinner<S>
impl<S> !RefUnwindSafe for Spinner<S>
impl<S> Send for Spinner<S>where
S: Send,
impl<S> !Sync for Spinner<S>
impl<S> Unpin for Spinner<S>where
S: Unpin,
impl<S> UnwindSafe for Spinner<S>where
S: UnwindSafe,
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