pub struct ProgressMetricSnapshot { /* private fields */ }Expand description
Snapshot of one metric counter within a progress event.
A progress event may carry multiple counters using different metric units,
such as entries and bytes. ProgressMetricSnapshot flattens one counter
together with the event-level phase, stage, and elapsed time so formatters
and consumers can handle one metric record at a time.
Implementations§
Source§impl ProgressMetricSnapshot
impl ProgressMetricSnapshot
Sourcepub fn new(
metric: ProgressMetric,
phase: ProgressPhase,
stage: Option<ProgressStage>,
counter: &ProgressCounter,
elapsed: Duration,
) -> Self
pub fn new( metric: ProgressMetric, phase: ProgressPhase, stage: Option<ProgressStage>, counter: &ProgressCounter, elapsed: Duration, ) -> Self
Creates a metric snapshot from explicit values.
§Parameters
metric- Complete metric metadata.phase- Lifecycle phase inherited from the source event.stage- Optional stage inherited from the source event.counter- Counter values copied into the snapshot.elapsed- Elapsed duration inherited from the source event.
§Returns
A flattened metric snapshot.
Sourcepub const fn metric(&self) -> &ProgressMetric
pub const fn metric(&self) -> &ProgressMetric
Sourcepub fn metric_name(&self) -> &str
pub fn metric_name(&self) -> &str
Returns the human-readable metric name.
§Returns
The metric display name associated with this snapshot.
Sourcepub const fn phase(&self) -> ProgressPhase
pub const fn phase(&self) -> ProgressPhase
Sourcepub const fn stage(&self) -> Option<&ProgressStage>
pub const fn stage(&self) -> Option<&ProgressStage>
Returns the optional stage.
§Returns
Some(stage) when the source event carried stage metadata, otherwise
None.
Sourcepub const fn total_count(&self) -> Option<u64>
pub const fn total_count(&self) -> Option<u64>
Returns the total work-unit count when known.
§Returns
Some(total) for known-total progress, or None for open-ended progress.
Sourcepub const fn completed_count(&self) -> u64
pub const fn completed_count(&self) -> u64
Sourcepub const fn active_count(&self) -> u64
pub const fn active_count(&self) -> u64
Sourcepub const fn succeeded_count(&self) -> u64
pub const fn succeeded_count(&self) -> u64
Sourcepub const fn failed_count(&self) -> u64
pub const fn failed_count(&self) -> u64
Sourcepub const fn remaining_count(&self) -> Option<u64>
pub const fn remaining_count(&self) -> Option<u64>
Returns the remaining work-unit count when the total is known.
§Returns
Some(total - completed - active) using saturating arithmetic for
known-total progress, or None when the total is unknown.
Sourcepub fn progress_fraction(&self) -> Option<f64>
pub fn progress_fraction(&self) -> Option<f64>
Returns completed progress as a fraction in 0.0..=1.0.
§Returns
Some(fraction) for known-total progress, Some(1.0) when the known
total is zero, or None when the total is unknown.
Sourcepub fn progress_percent(&self) -> Option<f64>
pub fn progress_percent(&self) -> Option<f64>
Returns completed progress as a percentage in 0.0..=100.0.
§Returns
Some(percent) for known-total progress, or None when the total is
unknown.
Trait Implementations§
Source§impl Clone for ProgressMetricSnapshot
impl Clone for ProgressMetricSnapshot
Source§fn clone(&self) -> ProgressMetricSnapshot
fn clone(&self) -> ProgressMetricSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProgressMetricSnapshot
impl Debug for ProgressMetricSnapshot
Source§impl<'de> Deserialize<'de> for ProgressMetricSnapshot
impl<'de> Deserialize<'de> for ProgressMetricSnapshot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ProgressMetricSnapshot
impl PartialEq for ProgressMetricSnapshot
Source§fn eq(&self, other: &ProgressMetricSnapshot) -> bool
fn eq(&self, other: &ProgressMetricSnapshot) -> bool
self and other values to be equal, and is used by ==.