Skip to main content

Progress

Struct Progress 

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

A progress display over one or more Tasks. Mirrors rich.progress.Progress.

Implementations§

Source§

impl Progress

Source

pub fn new() -> Self

Source

pub fn default_columns() -> Vec<ProgressColumn>

Upstream’s Progress.get_default_columns(): description, bar, percentage and time remaining.

Source

pub fn columns(self, columns: Vec<ProgressColumn>) -> Self

Replace the column list (default: default_columns).

Source

pub fn clock(self, clock: impl Fn() -> f64 + Send + Sync + 'static) -> Self

Read time from clock (seconds) instead of the monotonic clock. Upstream’s get_time; makes time-based columns deterministic.

Source

pub fn speed_estimate_period(self, seconds: f64) -> Self

Seconds of history used for speed estimates (default 30).

Source

pub fn add_task( &mut self, description: impl Into<String>, total: impl Into<Option<f64>>, completed: f64, ) -> TaskId

Add a started task and return its id. Port of Progress.add_task (start=True); total of None is an indeterminate task.

Source

pub fn add_unstarted_task( &mut self, description: impl Into<String>, total: impl Into<Option<f64>>, completed: f64, ) -> TaskId

Add a task that has not started (add_task(start=False)): it shows no elapsed time until start_task.

Source

pub fn task(&self, id: TaskId) -> Option<&Task>

The task with this id, if it has not been removed.

Source

pub fn tasks(&self) -> &[Task]

Every task, in the order added.

Source

pub fn finished(&self) -> bool

Whether every task has finished. Port of Progress.finished.

Source

pub fn start_task(&mut self, id: TaskId)

Start a task’s clock if it has not started. Port of start_task.

Source

pub fn stop_task(&mut self, id: TaskId)

Stop a task’s clock; its elapsed time freezes. Port of stop_task.

Source

pub fn update(&mut self, id: TaskId, update: TaskUpdate)

Update a task. Port of Progress.update: a new total clears the speed samples; positive progress adds a sample; reaching the total records the finish time.

Source

pub fn advance(&mut self, id: TaskId, amount: f64)

Advance a task by amount steps. Port of Progress.advance, which (unlike update) always records a sample and the finish speed.

Source

pub fn reset( &mut self, id: TaskId, start: bool, total: Option<f64>, completed: f64, )

Reset a task to completed, optionally restarting its clock and changing its total. Port of Progress.reset. Like upstream, a stop time set earlier is kept.

Source

pub fn remove_task(&mut self, id: TaskId)

Remove a task. Port of Progress.remove_task.

Trait Implementations§

Source§

impl Default for Progress

Source§

fn default() -> Self

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

impl Renderable for Progress

Source§

fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>

Source§

fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement

The (minimum, maximum) cell width this renderable wants. The default assumes the renderable fills the available width (e.g. Panel, Table); Text overrides it with its content width so the top-level print path can shrink to fit. Port of __rich_measure__ / Measurement.get.
Source§

fn fit_to_measurement(&self) -> bool

Whether a top-level Console::print shrinks this renderable to its measured width. The shrink stands in for upstream’s _collect_renderables, which joins printed str/Text values; other upstream renderables render at the full width, so one whose output pads to the width it is given (Syntax’s background) returns false.

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

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.