Struct throbber_widgets_tui::widgets::ThrobberState
source · 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 copy of the value. Read more
1.0.0 · 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
Auto Trait Implementations§
impl Freeze for ThrobberState
impl RefUnwindSafe for ThrobberState
impl Send for ThrobberState
impl Sync for ThrobberState
impl Unpin 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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