Skip to main content

ProgressBar

Struct ProgressBar 

Source
pub struct ProgressBar { /* private fields */ }
Expand description

A progress bar widget.

Displays a horizontal bar showing progress. In determinate mode, the bar fills proportionally. In indeterminate mode, an animated wave pattern moves across the bar.

Implementations§

Source§

impl ProgressBar

Source

pub fn new(progress: f32) -> Self

Create a determinate progress bar.

Progress is clamped to 0.0..=1.0.

Source

pub fn indeterminate() -> Self

Create an indeterminate progress bar.

Source

pub fn with_filled_style(self, style: Style) -> Self

Set the filled portion style.

Source

pub fn with_empty_style(self, style: Style) -> Self

Set the empty portion style.

Source

pub fn with_label_style(self, style: Style) -> Self

Set the percentage label style.

Source

pub fn with_show_percentage(self, show: bool) -> Self

Enable or disable percentage display.

Source

pub fn with_border(self, border: BorderStyle) -> Self

Set the border style.

Source

pub fn set_progress(&mut self, progress: f32)

Set the progress value (0.0 to 1.0, clamped).

Switches to determinate mode if currently indeterminate.

Source

pub fn progress(&self) -> Option<f32>

Get the current progress value.

Returns None if in indeterminate mode.

Source

pub fn tick(&mut self)

Advance the indeterminate animation phase.

In determinate mode, this is a no-op.

Source

pub fn mode(&self) -> &ProgressMode

Get the current mode.

Trait Implementations§

Source§

impl Widget for ProgressBar

Source§

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

Render this widget into the given area of the buffer.

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> 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, 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.