pub struct ThrobberState { /* private fields */ }Expand description
State to be used for Throbber render.
Implementations§
Source§impl ThrobberState
impl ThrobberState
Sourcepub fn calc_next(&mut self)
pub fn calc_next(&mut self)
Increase index.
§Examples:
let mut throbber_state = throbber_widgets_tui::ThrobberState::default();
assert_eq!(throbber_state.index(), 0);
throbber_state.calc_next();
assert_eq!(throbber_state.index(), 1);Sourcepub fn calc_step(&mut self, step: i8)
pub fn calc_step(&mut self, step: i8)
Calculate the index by specifying step.
Negative numbers can also be specified for step.
If step is 0, the index is determined at random.
§Examples:
let mut throbber_state = throbber_widgets_tui::ThrobberState::default();
assert_eq!(throbber_state.index(), 0);
throbber_state.calc_step(2);
assert_eq!(throbber_state.index(), 2);
throbber_state.calc_step(-3);
assert_eq!(throbber_state.index(), -1);
throbber_state.calc_step(0); // random
assert!((std::i8::MIN..=std::i8::MAX).contains(&throbber_state.index()))Sourcepub fn normalize(&mut self, throbber: &Throbber<'_>)
pub fn normalize(&mut self, throbber: &Throbber<'_>)
Set the index to the range of throbber_set.symbols.len().
This is called from render function automatically.
§Examples:
let mut throbber_state = throbber_widgets_tui::ThrobberState::default();
let throbber = throbber_widgets_tui::Throbber::default();
let len = 6; //throbber.throbber_set.symbols.len() as i8;
throbber_state.normalize(&throbber);
assert_eq!(throbber_state.index(), 0);
throbber_state.calc_step(len + 2);
assert_eq!(throbber_state.index(), len + 2);
throbber_state.normalize(&throbber);
assert_eq!(throbber_state.index(), 2);
// Negative numbers are indexed from backward
throbber_state.calc_step(-3 - len);
assert_eq!(throbber_state.index(), -1 - len);
throbber_state.normalize(&throbber);
assert_eq!(throbber_state.index(), len - 1);Trait Implementations§
Source§impl Clone for ThrobberState
impl Clone for ThrobberState
Source§fn clone(&self) -> ThrobberState
fn clone(&self) -> ThrobberState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ThrobberState
impl Debug for ThrobberState
Source§impl Default for ThrobberState
impl Default for ThrobberState
Source§fn default() -> ThrobberState
fn default() -> ThrobberState
Returns the “default value” for a type. Read more
impl Eq for ThrobberState
Source§impl PartialEq for ThrobberState
impl PartialEq for ThrobberState
impl StructuralPartialEq for ThrobberState
Auto Trait Implementations§
impl Freeze for ThrobberState
impl RefUnwindSafe for ThrobberState
impl Send for ThrobberState
impl Sync for ThrobberState
impl Unpin for ThrobberState
impl UnsafeUnpin for ThrobberState
impl UnwindSafe for ThrobberState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more