pub struct ProgressCounter { /* private fields */ }Expand description
Counters for one metric in a progress event.
A counter is identified by metric_id. The corresponding display name and
metric dictionary entry live in ProgressSchema.
Counter values are u64 so they can represent domain quantities such as
bytes, records, objects, or files independently of the current platform’s
pointer width.
§Examples
use qubit_progress::ProgressCounter;
let counter = ProgressCounter::new("bytes")
.total(10_000)
.completed(4_000)
.active(1);
assert_eq!(counter.metric_id(), "bytes");
assert_eq!(counter.total_count(), Some(10_000));
assert_eq!(counter.progress_percent(), Some(40.0));Implementations§
Source§impl ProgressCounter
impl ProgressCounter
Sourcepub const fn with_total_count(self, total_count: Option<u64>) -> Self
pub const fn with_total_count(self, total_count: Option<u64>) -> Self
Sourcepub const fn unknown_total(self) -> Self
pub const fn unknown_total(self) -> Self
Sourcepub const fn with_completed_count(self, completed_count: u64) -> Self
pub const fn with_completed_count(self, completed_count: u64) -> Self
Sourcepub const fn with_active_count(self, active_count: u64) -> Self
pub const fn with_active_count(self, active_count: u64) -> Self
Sourcepub const fn with_succeeded_count(self, succeeded_count: u64) -> Self
pub const fn with_succeeded_count(self, succeeded_count: u64) -> Self
Sourcepub const fn with_failed_count(self, failed_count: u64) -> Self
pub const fn with_failed_count(self, failed_count: u64) -> Self
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 ProgressCounter
impl Clone for ProgressCounter
Source§fn clone(&self) -> ProgressCounter
fn clone(&self) -> ProgressCounter
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 ProgressCounter
impl Debug for ProgressCounter
Source§impl<'de> Deserialize<'de> for ProgressCounter
impl<'de> Deserialize<'de> for ProgressCounter
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 Hash for ProgressCounter
impl Hash for ProgressCounter
Source§impl PartialEq for ProgressCounter
impl PartialEq for ProgressCounter
Source§fn eq(&self, other: &ProgressCounter) -> bool
fn eq(&self, other: &ProgressCounter) -> bool
self and other values to be equal, and is used by ==.