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>
impl<'a> ProgressWidget<'a>
Sourcepub fn new(ratio: f64) -> Self
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.
Sourcepub const fn label(self, label: &'a str) -> Self
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.
Sourcepub const fn show_value(self, show_value: bool) -> Self
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.
Sourcepub const fn style(self, style: ProgressStyle) -> Self
pub const fn style(self, style: ProgressStyle) -> Self
Use these exact colors, ignoring any theme.
Sourcepub const fn height(&self) -> u16
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>
impl<'a> Clone for ProgressWidget<'a>
Source§fn clone(&self) -> ProgressWidget<'a>
fn clone(&self) -> ProgressWidget<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for ProgressWidget<'a>
impl<'a> Debug for ProgressWidget<'a>
Source§impl<'a> PartialEq for ProgressWidget<'a>
impl<'a> PartialEq for ProgressWidget<'a>
impl<'a> StructuralPartialEq for ProgressWidget<'a>
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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