Skip to main content

Progress

Struct Progress 

Source
pub struct Progress {
    pub width: usize,
    pub full_char: char,
    pub full_color: String,
    pub empty_char: char,
    pub empty_color: String,
    pub show_percentage: bool,
    pub percent_format: String,
    pub percentage_style: Style,
    /* private fields */
}
Expand description

Progress bar model.

Fields§

§width: usize

Total width of the progress bar.

§full_char: char

Character for filled sections.

§full_color: String

Color for filled sections (when not using gradient).

§empty_char: char

Character for empty sections.

§empty_color: String

Color for empty sections.

§show_percentage: bool

Whether to show percentage text.

§percent_format: String

Format string for percentage.

§percentage_style: Style

Style for percentage text.

Implementations§

Source§

impl Progress

Source

pub fn new() -> Self

Creates a new progress bar with default settings.

Source

pub fn with_gradient() -> Self

Creates a progress bar with default gradient colors.

Source

pub fn with_gradient_colors(color_a: &str, color_b: &str) -> Self

Creates a progress bar with custom gradient colors.

Source

pub fn with_scaled_gradient(color_a: &str, color_b: &str) -> Self

Creates a progress bar with a scaled gradient.

Source

pub fn width(self, width: usize) -> Self

Sets the width of the progress bar.

Source

pub fn fill_chars(self, full: char, empty: char) -> Self

Sets the fill characters.

Source

pub fn solid_fill(self, color: &str) -> Self

Sets the solid fill color (disables gradient).

Source

pub fn without_percentage(self) -> Self

Disables percentage display.

Source

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

Sets the spring animation parameters.

Source

pub fn id(&self) -> u64

Returns the progress bar’s unique ID.

Source

pub fn percent(&self) -> f64

Returns the current target percentage.

Source

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

Sets the percentage and returns a command to start animation.

Source

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

Increments the percentage.

Source

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

Decrements the percentage.

Source

pub fn is_animating(&self) -> bool

Returns whether the progress bar is still animating.

Source

pub fn update(&mut self, msg: Message) -> Option<Cmd>

Updates the progress bar state.

Source

pub fn view(&self) -> String

Renders the progress bar at the current animated position.

Source

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

Renders the progress bar at a specific percentage.

Trait Implementations§

Source§

impl Clone for Progress

Source§

fn clone(&self) -> Progress

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Progress

Source§

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

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

impl Default for Progress

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Model for Progress

Source§

fn init(&self) -> Option<Cmd>

Initialize the progress bar.

Progress bars don’t require initialization commands.

Source§

fn update(&mut self, msg: Message) -> Option<Cmd>

Update the progress bar state based on incoming messages.

Source§

fn view(&self) -> String

Render the progress bar at the current animated position.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more