pub struct ProgressCounters { /* private fields */ }Expand description
Generic progress counters for a running operation.
§Examples
use qubit_progress::ProgressCounters;
let counters = ProgressCounters::new(Some(10))
.with_completed_count(4)
.with_active_count(2)
.with_succeeded_count(3);
assert_eq!(counters.total_count(), Some(10));
assert_eq!(counters.remaining_count(), Some(4));
assert_eq!(counters.progress_percent(), Some(40.0));Implementations§
Source§impl ProgressCounters
impl ProgressCounters
Sourcepub const fn with_total_count(self, total_count: Option<usize>) -> Self
pub const fn with_total_count(self, total_count: Option<usize>) -> Self
Sourcepub const fn with_completed_count(self, completed_count: usize) -> Self
pub const fn with_completed_count(self, completed_count: usize) -> Self
Sourcepub const fn with_active_count(self, active_count: usize) -> Self
pub const fn with_active_count(self, active_count: usize) -> Self
Sourcepub const fn with_succeeded_count(self, succeeded_count: usize) -> Self
pub const fn with_succeeded_count(self, succeeded_count: usize) -> Self
Sourcepub const fn with_failed_count(self, failed_count: usize) -> Self
pub const fn with_failed_count(self, failed_count: usize) -> Self
Sourcepub const fn total_count(&self) -> Option<usize>
pub const fn total_count(&self) -> Option<usize>
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) -> usize
pub const fn completed_count(&self) -> usize
Sourcepub const fn active_count(&self) -> usize
pub const fn active_count(&self) -> usize
Sourcepub const fn succeeded_count(&self) -> usize
pub const fn succeeded_count(&self) -> usize
Sourcepub const fn failed_count(&self) -> usize
pub const fn failed_count(&self) -> usize
Sourcepub const fn remaining_count(&self) -> Option<usize>
pub const fn remaining_count(&self) -> Option<usize>
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 ProgressCounters
impl Clone for ProgressCounters
Source§fn clone(&self) -> ProgressCounters
fn clone(&self) -> ProgressCounters
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ProgressCounters
impl Debug for ProgressCounters
Source§impl Hash for ProgressCounters
impl Hash for ProgressCounters
Source§impl PartialEq for ProgressCounters
impl PartialEq for ProgressCounters
Source§fn eq(&self, other: &ProgressCounters) -> bool
fn eq(&self, other: &ProgressCounters) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for ProgressCounters
impl Eq for ProgressCounters
impl StructuralPartialEq for ProgressCounters
Auto Trait Implementations§
impl Freeze for ProgressCounters
impl RefUnwindSafe for ProgressCounters
impl Send for ProgressCounters
impl Sync for ProgressCounters
impl Unpin for ProgressCounters
impl UnsafeUnpin for ProgressCounters
impl UnwindSafe for ProgressCounters
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