pub struct Progress { /* private fields */ }Expand description
A progress display over one or more Tasks. Mirrors rich.progress.Progress.
Implementations§
Source§impl Progress
impl Progress
pub fn new() -> Self
Sourcepub fn default_columns() -> Vec<ProgressColumn>
pub fn default_columns() -> Vec<ProgressColumn>
Upstream’s Progress.get_default_columns(): description, bar,
percentage and time remaining.
Sourcepub fn columns(self, columns: Vec<ProgressColumn>) -> Self
pub fn columns(self, columns: Vec<ProgressColumn>) -> Self
Replace the column list (default: default_columns).
Sourcepub fn clock(self, clock: impl Fn() -> f64 + Send + Sync + 'static) -> Self
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.
Sourcepub fn speed_estimate_period(self, seconds: f64) -> Self
pub fn speed_estimate_period(self, seconds: f64) -> Self
Seconds of history used for speed estimates (default 30).
Sourcepub fn add_task(
&mut self,
description: impl Into<String>,
total: impl Into<Option<f64>>,
completed: f64,
) -> TaskId
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.
Sourcepub fn add_unstarted_task(
&mut self,
description: impl Into<String>,
total: impl Into<Option<f64>>,
completed: f64,
) -> TaskId
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.
Sourcepub fn task(&self, id: TaskId) -> Option<&Task>
pub fn task(&self, id: TaskId) -> Option<&Task>
The task with this id, if it has not been removed.
Sourcepub fn start_task(&mut self, id: TaskId)
pub fn start_task(&mut self, id: TaskId)
Start a task’s clock if it has not started. Port of start_task.
Sourcepub fn stop_task(&mut self, id: TaskId)
pub fn stop_task(&mut self, id: TaskId)
Stop a task’s clock; its elapsed time freezes. Port of stop_task.
Sourcepub fn update(&mut self, id: TaskId, update: TaskUpdate)
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.
Sourcepub fn advance(&mut self, id: TaskId, amount: f64)
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.
Sourcepub fn reset(
&mut self,
id: TaskId,
start: bool,
total: Option<f64>,
completed: f64,
)
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.
Sourcepub fn remove_task(&mut self, id: TaskId)
pub fn remove_task(&mut self, id: TaskId)
Remove a task. Port of Progress.remove_task.
Trait Implementations§
Source§impl Renderable for Progress
impl Renderable for Progress
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Source§fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
(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
fn fit_to_measurement(&self) -> bool
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.