Skip to main content

ProgressSnapshot

Struct ProgressSnapshot 

Source
pub struct ProgressSnapshot {
    pub kind: ProgressType,
    pub name: CompactString,
    pub item: CompactString,
    pub elapsed: Option<Duration>,
    pub position: u64,
    pub total: u64,
    pub finished: bool,
    pub error: Option<CompactString>,
}
Expand description

A plain-data snapshot of a Progress state at a specific point in time.

This is typically used for rendering, as it holds owned data and requires no locking to access.

Fields§

§kind: ProgressType

The type of progress indicator.

§name: CompactString

The name/label of the progress task.

§item: CompactString

The current item description.

§elapsed: Option<Duration>

The elapsed duration.

§position: u64

The current position.

§total: u64

The total target count.

§finished: bool

Whether the task is finished.

§error: Option<CompactString>

The associated error message, if any.

Implementations§

Source§

impl ProgressSnapshot

Source

pub const fn kind(&self) -> ProgressType

Returns the type of progress indicator.

Source

pub fn name(&self) -> &str

Returns the name/label of the progress task.

Source

pub fn item(&self) -> &str

Returns the current item description.

Source

pub const fn elapsed(&self) -> Option<Duration>

Returns the elapsed duration.

Source

pub const fn position(&self) -> u64

Returns the current position.

Source

pub const fn total(&self) -> u64

Returns the total target count.

Source

pub const fn finished(&self) -> bool

Returns whether the task is finished.

Source

pub fn error(&self) -> Option<&str>

Returns the error message, if any.

Source

pub fn eta(&self) -> Option<Duration>

Estimates the time remaining (ETA) based on average speed since start.

Returns None if:

  • No progress has been made.
  • Total is zero.
  • Process is finished.
  • Elapsed time is effectively zero.
Source

pub fn throughput(&self) -> f64

Calculates the average throughput (items per second) over the entire lifetime.

Source

pub fn throughput_since(&self, prev: &Self) -> f64

Calculates the instantaneous throughput relative to a previous snapshot.

This is useful for calculating “current speed” (e.g., in the last second).

Trait Implementations§

Source§

impl Clone for ProgressSnapshot

Source§

fn clone(&self) -> ProgressSnapshot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProgressSnapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProgressSnapshot

Source§

fn default() -> ProgressSnapshot

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

impl Eq for ProgressSnapshot

Source§

impl From<&Progress> for ProgressSnapshot

Source§

fn from(progress: &Progress) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ProgressSnapshot

Source§

fn eq(&self, other: &ProgressSnapshot) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ProgressSnapshot

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.