Skip to main content

Model

Struct Model 

Source
pub struct Model {
    pub full: char,
    pub full_color: Color,
    pub empty: char,
    pub empty_color: Color,
    pub show_percentage: bool,
    pub percent_format: String,
    pub percentage_style: Style,
    /* private fields */
}
Expand description

Model stores values we’ll use when rendering the progress bar.

Fields§

§full: char

“Filled” sections of the progress bar.

§full_color: Color

The color used for the filled sections.

§empty: char

“Empty” sections of the progress bar.

§empty_color: Color

The color used for the empty sections.

§show_percentage: bool

Settings for rendering the numeric percentage.

§percent_format: String

A fmt string for a float.

§percentage_style: Style

The style used for the percentage.

Implementations§

Source§

impl Model

Source

pub fn update(&mut self, msg: &dyn Msg) -> Cmd

Update is used to animate the progress bar during transitions. Use set_percent to create the command you’ll need to trigger the animation.

If you’re rendering with view_as you won’t need this.

Source

pub fn set_spring_options(&mut self, frequency: f64, damping: f64)

SetSpringOptions sets the frequency and damping for the current spring. Frequency corresponds to speed, and damping to bounciness.

Source

pub fn percent(&self) -> f64

Percent returns the current visible percentage on the model. This is only relevant when you’re animating the progress bar.

If you’re rendering with view_as you won’t need this.

Source

pub fn set_percent(&mut self, p: f64) -> Cmd

SetPercent sets the percentage state of the model as well as a command necessary for animating the progress bar to this new percentage.

If you’re rendering with view_as you won’t need this.

Source

pub fn incr_percent(&mut self, v: f64) -> Cmd

IncrPercent increments the percentage by a given amount, returning a command necessary to animate the progress bar to the new percentage.

If you’re rendering with view_as you won’t need this.

Source

pub fn decr_percent(&mut self, v: f64) -> Cmd

DecrPercent decrements the percentage by a given amount, returning a command necessary to animate the progress bar to the new percentage.

If you’re rendering with view_as you won’t need this.

Source

pub fn view(&self) -> String

View renders an animated progress bar in its current state. To render a static progress bar based on your own calculations use view_as instead.

Source

pub fn view_as(&self, percent: f64) -> String

ViewAs renders the progress bar with a given percentage.

Source

pub fn set_width(&mut self, w: usize)

SetWidth sets the width of the progress bar.

Source

pub fn width(&self) -> usize

Width returns the width of the progress bar.

Source

pub fn is_animating(&self) -> bool

IsAnimating returns false if the progress bar reached equilibrium and is no longer animating.

Trait Implementations§

Source§

impl Debug for Model

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Model

§

impl !UnwindSafe for Model

§

impl Freeze for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

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> Msg for T
where T: Any + Send + Sync + Debug,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Helper to downcast to Any.
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Consumes the boxed message and returns it as a Box<dyn Any>, so the program can move the concrete message out of the trait object (used to dispatch the commands carried by BatchMsg/SequenceMsg).
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.