Skip to main content

LiveProgress

Struct LiveProgress 

Source
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>

Source

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.

Source

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

Source

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

Progress::reset, then redraw (upstream’s reset refreshes).

Source

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

Source

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

Progress::update; redraws when the update asks to (TaskUpdate::refresh).

Source

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.

Source

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.

Source

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.

Source

pub fn open( &self, path: impl AsRef<Path>, total: Option<u64>, task: Option<TaskId>, description: impl Into<String>, ) -> Result<ProgressReader<'_, File, W>>

Open path for reading and track it. Port of Progress.open in binary mode: total defaults to the file’s size.

Source

pub fn stop(self) -> (Progress, W)

Commit the final frame, stop the refresh thread, and return the progress and the output sink. Port of Progress.stop.

Auto Trait Implementations§

§

impl<W> !Freeze for LiveProgress<W>

§

impl<W> !RefUnwindSafe for LiveProgress<W>

§

impl<W> !UnwindSafe for LiveProgress<W>

§

impl<W> Send for LiveProgress<W>
where Option<AutoLive<W>>: Send, Option<W>: Send,

§

impl<W> Sync for LiveProgress<W>
where Option<AutoLive<W>>: Sync, Option<W>: Sync,

§

impl<W> Unpin for LiveProgress<W>
where Option<AutoLive<W>>: Unpin, Option<W>: Unpin,

§

impl<W> UnsafeUnpin for LiveProgress<W>

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.