Loading

Struct Loading 

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

Implementations§

Source§

impl Loading

Source

pub fn with_stdout(spinner: Spinner) -> Self

Create a stdout loading

Examples found in repository?
examples/spinner.rs (line 6)
5fn main() {
6    let loading = Loading::with_stdout(Spinner::new(vec!["◐", "◓", "◑", "◒"]));
7    for i in 0..10 {
8        loading.text(format!("Loading {}", i));
9        thread::sleep(Duration::from_millis(200));
10    }
11    loading.success("Successs ...");
12    loading.end();
13
14    let loading = Loading::with_stderr(Spinner::new(vec!["∙∙∙", "●∙∙", "∙●∙", "∙∙●"]));
15    for i in 0..10 {
16        loading.text(format!("Loading {}", i));
17        thread::sleep(Duration::from_millis(200));
18    }
19    loading.fail("Error ...");
20    loading.end();
21}
Source

pub fn with_stderr(spinner: Spinner) -> Self

Create a stderr loading

Examples found in repository?
examples/spinner.rs (line 14)
5fn main() {
6    let loading = Loading::with_stdout(Spinner::new(vec!["◐", "◓", "◑", "◒"]));
7    for i in 0..10 {
8        loading.text(format!("Loading {}", i));
9        thread::sleep(Duration::from_millis(200));
10    }
11    loading.success("Successs ...");
12    loading.end();
13
14    let loading = Loading::with_stderr(Spinner::new(vec!["∙∙∙", "●∙∙", "∙●∙", "∙∙●"]));
15    for i in 0..10 {
16        loading.text(format!("Loading {}", i));
17        thread::sleep(Duration::from_millis(200));
18    }
19    loading.fail("Error ...");
20    loading.end();
21}
Source

pub fn end(self)

End loading

Examples found in repository?
examples/loading.rs (line 15)
5fn main() {
6    let loading = Loading::default();
7
8    for i in 0..=100 {
9        loading.text(format!("Loading {}", i));
10        thread::sleep(Duration::from_millis(50));
11    }
12
13    loading.success("OK");
14
15    loading.end();
16}
More examples
Hide additional examples
examples/download.rs (line 22)
5fn main() {
6    let loading = Loading::default();
7
8    for i in 0..100 {
9        loading.text(format!("Download 'loading.rar' {}%", i));
10        thread::sleep(Duration::from_millis(30));
11    }
12
13    loading.fail("Download 'loading.rar' failed");
14
15    for i in 0..100 {
16        loading.text(format!("Download 'loading.zip' {}%", i));
17        thread::sleep(Duration::from_millis(30));
18    }
19
20    loading.success("Download 'loading.zip' successfully");
21
22    loading.end();
23}
examples/status.rs (line 22)
5fn main() {
6    let loading = Loading::default();
7
8    for status in 0..4 {
9        for i in 0..5 {
10            loading.text(format!("Loading {}", i));
11            thread::sleep(Duration::from_millis(200));
12        }
13        match status {
14            0 => loading.fail("Fail ..."),
15            1 => loading.warn("Warn ..."),
16            2 => loading.info("Info ..."),
17            3 => loading.success("Successs ..."),
18            _ => {}
19        };
20    }
21
22    loading.end();
23}
examples/spinner.rs (line 12)
5fn main() {
6    let loading = Loading::with_stdout(Spinner::new(vec!["◐", "◓", "◑", "◒"]));
7    for i in 0..10 {
8        loading.text(format!("Loading {}", i));
9        thread::sleep(Duration::from_millis(200));
10    }
11    loading.success("Successs ...");
12    loading.end();
13
14    let loading = Loading::with_stderr(Spinner::new(vec!["∙∙∙", "●∙∙", "∙●∙", "∙∙●"]));
15    for i in 0..10 {
16        loading.text(format!("Loading {}", i));
17        thread::sleep(Duration::from_millis(200));
18    }
19    loading.fail("Error ...");
20    loading.end();
21}
Source

pub fn text<T: ToString>(&self, text: T)

Modify the currently displayed text

Examples found in repository?
examples/loading.rs (line 9)
5fn main() {
6    let loading = Loading::default();
7
8    for i in 0..=100 {
9        loading.text(format!("Loading {}", i));
10        thread::sleep(Duration::from_millis(50));
11    }
12
13    loading.success("OK");
14
15    loading.end();
16}
More examples
Hide additional examples
examples/download.rs (line 9)
5fn main() {
6    let loading = Loading::default();
7
8    for i in 0..100 {
9        loading.text(format!("Download 'loading.rar' {}%", i));
10        thread::sleep(Duration::from_millis(30));
11    }
12
13    loading.fail("Download 'loading.rar' failed");
14
15    for i in 0..100 {
16        loading.text(format!("Download 'loading.zip' {}%", i));
17        thread::sleep(Duration::from_millis(30));
18    }
19
20    loading.success("Download 'loading.zip' successfully");
21
22    loading.end();
23}
examples/status.rs (line 10)
5fn main() {
6    let loading = Loading::default();
7
8    for status in 0..4 {
9        for i in 0..5 {
10            loading.text(format!("Loading {}", i));
11            thread::sleep(Duration::from_millis(200));
12        }
13        match status {
14            0 => loading.fail("Fail ..."),
15            1 => loading.warn("Warn ..."),
16            2 => loading.info("Info ..."),
17            3 => loading.success("Successs ..."),
18            _ => {}
19        };
20    }
21
22    loading.end();
23}
examples/spinner.rs (line 8)
5fn main() {
6    let loading = Loading::with_stdout(Spinner::new(vec!["◐", "◓", "◑", "◒"]));
7    for i in 0..10 {
8        loading.text(format!("Loading {}", i));
9        thread::sleep(Duration::from_millis(200));
10    }
11    loading.success("Successs ...");
12    loading.end();
13
14    let loading = Loading::with_stderr(Spinner::new(vec!["∙∙∙", "●∙∙", "∙●∙", "∙∙●"]));
15    for i in 0..10 {
16        loading.text(format!("Loading {}", i));
17        thread::sleep(Duration::from_millis(200));
18    }
19    loading.fail("Error ...");
20    loading.end();
21}
Source

pub fn success<T: ToString>(&self, text: T)

Save the current line as ‘success’ and continue to load on the next line

Examples found in repository?
examples/loading.rs (line 13)
5fn main() {
6    let loading = Loading::default();
7
8    for i in 0..=100 {
9        loading.text(format!("Loading {}", i));
10        thread::sleep(Duration::from_millis(50));
11    }
12
13    loading.success("OK");
14
15    loading.end();
16}
More examples
Hide additional examples
examples/download.rs (line 20)
5fn main() {
6    let loading = Loading::default();
7
8    for i in 0..100 {
9        loading.text(format!("Download 'loading.rar' {}%", i));
10        thread::sleep(Duration::from_millis(30));
11    }
12
13    loading.fail("Download 'loading.rar' failed");
14
15    for i in 0..100 {
16        loading.text(format!("Download 'loading.zip' {}%", i));
17        thread::sleep(Duration::from_millis(30));
18    }
19
20    loading.success("Download 'loading.zip' successfully");
21
22    loading.end();
23}
examples/status.rs (line 17)
5fn main() {
6    let loading = Loading::default();
7
8    for status in 0..4 {
9        for i in 0..5 {
10            loading.text(format!("Loading {}", i));
11            thread::sleep(Duration::from_millis(200));
12        }
13        match status {
14            0 => loading.fail("Fail ..."),
15            1 => loading.warn("Warn ..."),
16            2 => loading.info("Info ..."),
17            3 => loading.success("Successs ..."),
18            _ => {}
19        };
20    }
21
22    loading.end();
23}
examples/spinner.rs (line 11)
5fn main() {
6    let loading = Loading::with_stdout(Spinner::new(vec!["◐", "◓", "◑", "◒"]));
7    for i in 0..10 {
8        loading.text(format!("Loading {}", i));
9        thread::sleep(Duration::from_millis(200));
10    }
11    loading.success("Successs ...");
12    loading.end();
13
14    let loading = Loading::with_stderr(Spinner::new(vec!["∙∙∙", "●∙∙", "∙●∙", "∙∙●"]));
15    for i in 0..10 {
16        loading.text(format!("Loading {}", i));
17        thread::sleep(Duration::from_millis(200));
18    }
19    loading.fail("Error ...");
20    loading.end();
21}
Source

pub fn fail<T: ToString>(&self, text: T)

Save the current line as ‘fail’ and continue to load on the next line

Examples found in repository?
examples/download.rs (line 13)
5fn main() {
6    let loading = Loading::default();
7
8    for i in 0..100 {
9        loading.text(format!("Download 'loading.rar' {}%", i));
10        thread::sleep(Duration::from_millis(30));
11    }
12
13    loading.fail("Download 'loading.rar' failed");
14
15    for i in 0..100 {
16        loading.text(format!("Download 'loading.zip' {}%", i));
17        thread::sleep(Duration::from_millis(30));
18    }
19
20    loading.success("Download 'loading.zip' successfully");
21
22    loading.end();
23}
More examples
Hide additional examples
examples/status.rs (line 14)
5fn main() {
6    let loading = Loading::default();
7
8    for status in 0..4 {
9        for i in 0..5 {
10            loading.text(format!("Loading {}", i));
11            thread::sleep(Duration::from_millis(200));
12        }
13        match status {
14            0 => loading.fail("Fail ..."),
15            1 => loading.warn("Warn ..."),
16            2 => loading.info("Info ..."),
17            3 => loading.success("Successs ..."),
18            _ => {}
19        };
20    }
21
22    loading.end();
23}
examples/spinner.rs (line 19)
5fn main() {
6    let loading = Loading::with_stdout(Spinner::new(vec!["◐", "◓", "◑", "◒"]));
7    for i in 0..10 {
8        loading.text(format!("Loading {}", i));
9        thread::sleep(Duration::from_millis(200));
10    }
11    loading.success("Successs ...");
12    loading.end();
13
14    let loading = Loading::with_stderr(Spinner::new(vec!["∙∙∙", "●∙∙", "∙●∙", "∙∙●"]));
15    for i in 0..10 {
16        loading.text(format!("Loading {}", i));
17        thread::sleep(Duration::from_millis(200));
18    }
19    loading.fail("Error ...");
20    loading.end();
21}
Source

pub fn warn<T: ToString>(&self, text: T)

Save the current line as ‘warn’ and continue to load on the next line

Examples found in repository?
examples/status.rs (line 15)
5fn main() {
6    let loading = Loading::default();
7
8    for status in 0..4 {
9        for i in 0..5 {
10            loading.text(format!("Loading {}", i));
11            thread::sleep(Duration::from_millis(200));
12        }
13        match status {
14            0 => loading.fail("Fail ..."),
15            1 => loading.warn("Warn ..."),
16            2 => loading.info("Info ..."),
17            3 => loading.success("Successs ..."),
18            _ => {}
19        };
20    }
21
22    loading.end();
23}
Source

pub fn info<T: ToString>(&self, text: T)

Save the current line as ‘info’ and continue to load on the next line

Examples found in repository?
examples/status.rs (line 16)
5fn main() {
6    let loading = Loading::default();
7
8    for status in 0..4 {
9        for i in 0..5 {
10            loading.text(format!("Loading {}", i));
11            thread::sleep(Duration::from_millis(200));
12        }
13        match status {
14            0 => loading.fail("Fail ..."),
15            1 => loading.warn("Warn ..."),
16            2 => loading.info("Info ..."),
17            3 => loading.success("Successs ..."),
18            _ => {}
19        };
20    }
21
22    loading.end();
23}

Trait Implementations§

Source§

impl Debug for Loading

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Loading

Source§

fn default() -> Self

Returns the “default value” for a type. 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 = 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 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.