Skip to main content

ProgressWidget

Struct ProgressWidget 

Source
pub struct ProgressWidget<'a> { /* private fields */ }
Expand description

A progress bar — the fill’s share of the track is the work done.

One instantiation is one bar. The ratio arrives through new; label and show_value compose the header above the track; and themed or style choose the colors.

Implementations§

Source§

impl<'a> ProgressWidget<'a>

Source

pub fn new(ratio: f64) -> Self

A bare bar filled by ratio, where 0.0 is empty and 1.0 is full.

Values outside 0.0..=1.0 are clamped: infinities pin to the nearer end, and a NaN that slipped out of a division counts as empty rather than printing itself as a percentage.

Source

pub const fn label(self, label: &'a str) -> Self

Label the bar — the task’s name, above the fill, left-aligned. Pair it with show_value to complete the composition: name on the left, percentage on the right, bar underneath.

Source

pub const fn show_value(self, show_value: bool) -> Self

Print the percentage right-aligned above the bar. Rounded to the nearest whole percent, 0% through 100%. The percentage and the fill round independently — ratatui’s gauge rounds its last cell in eighths — so at a width’s rounding edge the number can briefly sit one eighth of a cell away from the bar it describes. On a row too narrow for the number, what fits of it prints, digits first.

Source

pub const fn themed(self, theme: &Theme) -> Self

Take colors from theme.

Source

pub const fn style(self, style: ProgressStyle) -> Self

Use these exact colors, ignoring any theme.

Source

pub const fn height(&self) -> u16

Rows the bar asks a layout for: two when a label or the percentage shows, one otherwise — an empty label still shows, since you asked for the row. Given less, the bar keeps the rows there are and the header is the first thing dropped; given more, the extra rows are left alone — a progress bar is one row of track, not a block meter.

Trait Implementations§

Source§

impl<'a> Clone for ProgressWidget<'a>

Source§

fn clone(&self) -> ProgressWidget<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for ProgressWidget<'a>

Source§

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

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

impl<'a> PartialEq for ProgressWidget<'a>

Source§

fn eq(&self, other: &ProgressWidget<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for ProgressWidget<'a>

Source§

impl Widget for ProgressWidget<'_>

Source§

fn render(self, area: Rect, buf: &mut Buffer)

Draws the current state of the widget in the given buffer. That is the only method required to implement a custom widget.

Auto Trait Implementations§

§

impl<'a> Freeze for ProgressWidget<'a>

§

impl<'a> RefUnwindSafe for ProgressWidget<'a>

§

impl<'a> Send for ProgressWidget<'a>

§

impl<'a> Sync for ProgressWidget<'a>

§

impl<'a> Unpin for ProgressWidget<'a>

§

impl<'a> UnsafeUnpin for ProgressWidget<'a>

§

impl<'a> UnwindSafe for ProgressWidget<'a>

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, 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.