pub struct LiveProgress<W: Write + Send + 'static> { /* private fields */ }Expand description
A running Progress display. Task changes made through it are picked up
by the next refresh, as with upstream’s refresh=False updates.
Implementations§
Source§impl<W: Write + Send + 'static> LiveProgress<W>
impl<W: Write + Send + 'static> LiveProgress<W>
Sourcepub fn with<R>(&self, f: impl FnOnce(&mut Progress) -> R) -> R
pub fn with<R>(&self, f: impl FnOnce(&mut Progress) -> R) -> R
Run f with the progress locked, for any change not wrapped below.
f may call refresh (the frame is drawn as soon as
the lock is released), but not with or a method built on it: upstream
re-enters its RLock, which a &mut Progress cannot express, so a
nested call panics instead of deadlocking.
Sourcepub fn add_task(
&self,
description: impl Into<String>,
total: impl Into<Option<f64>>,
completed: f64,
) -> TaskId
pub fn add_task( &self, description: impl Into<String>, total: impl Into<Option<f64>>, completed: f64, ) -> TaskId
Progress::add_task, then redraw (upstream’s add_task refreshes).
Sourcepub fn reset(&self, id: TaskId, start: bool, total: Option<f64>, completed: f64)
pub fn reset(&self, id: TaskId, start: bool, total: Option<f64>, completed: f64)
Progress::reset, then redraw (upstream’s reset refreshes).
Sourcepub fn update(&self, id: TaskId, update: TaskUpdate)
pub fn update(&self, id: TaskId, update: TaskUpdate)
Progress::update; redraws when the update asks to
(TaskUpdate::refresh).
Sourcepub fn refresh(&self)
pub fn refresh(&self)
Redraw now rather than at the next tick, returning once the frame is
written. Port of Progress.refresh.
Called from inside with, the redraw is queued instead:
the refresh thread needs the lock this thread holds to render, so
waiting for it would deadlock. The frame is drawn when with returns.
Sourcepub fn track<I: IntoIterator>(
&self,
iter: I,
total: Option<f64>,
description: impl Into<String>,
) -> Track<'_, I::IntoIter, W> ⓘ
pub fn track<I: IntoIterator>( &self, iter: I, total: Option<f64>, description: impl Into<String>, ) -> Track<'_, I::IntoIter, W> ⓘ
Iterate iter, advancing a new task by one after each item is
processed. Port of Progress.track: the total defaults to the
iterator’s exact length, else the task is indeterminate.
Sourcepub fn wrap_read<R: Read>(
&self,
reader: R,
total: Option<u64>,
task: Option<TaskId>,
description: impl Into<String>,
) -> Result<ProgressReader<'_, R, W>>
pub fn wrap_read<R: Read>( &self, reader: R, total: Option<u64>, task: Option<TaskId>, description: impl Into<String>, ) -> Result<ProgressReader<'_, R, W>>
Track reading from reader: each read advances the task by the bytes
read. Port of Progress.wrap_file: total is the byte count, or else
the total of task; a new task named description is added when
task is None, otherwise task’s total is set.