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: ProgressTypeThe type of progress indicator.
name: CompactStringThe name/label of the progress task.
item: CompactStringThe current item description.
elapsed: Option<Duration>The elapsed duration.
position: u64The current position.
total: u64The total target count.
finished: boolWhether the task is finished.
error: Option<CompactString>The associated error message, if any.
Implementations§
Source§impl ProgressSnapshot
impl ProgressSnapshot
Sourcepub const fn kind(&self) -> ProgressType
pub const fn kind(&self) -> ProgressType
Returns the type of progress indicator.
Sourcepub fn eta(&self) -> Option<Duration>
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.
Sourcepub fn throughput(&self) -> f64
pub fn throughput(&self) -> f64
Calculates the average throughput (items per second) over the entire lifetime.
Sourcepub fn throughput_since(&self, prev: &Self) -> f64
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
impl Clone for ProgressSnapshot
Source§fn clone(&self) -> ProgressSnapshot
fn clone(&self) -> ProgressSnapshot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ProgressSnapshot
impl Debug for ProgressSnapshot
Source§impl Default for ProgressSnapshot
impl Default for ProgressSnapshot
Source§fn default() -> ProgressSnapshot
fn default() -> ProgressSnapshot
Returns the “default value” for a type. Read more
Source§impl From<&Progress> for ProgressSnapshot
impl From<&Progress> for ProgressSnapshot
Source§impl PartialEq for ProgressSnapshot
impl PartialEq for ProgressSnapshot
impl Eq for ProgressSnapshot
impl StructuralPartialEq for ProgressSnapshot
Auto Trait Implementations§
impl Freeze for ProgressSnapshot
impl RefUnwindSafe for ProgressSnapshot
impl Send for ProgressSnapshot
impl Sync for ProgressSnapshot
impl Unpin for ProgressSnapshot
impl UnwindSafe for ProgressSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more