Skip to main content

ProgressCounters

Struct ProgressCounters 

Source
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

Source

pub const fn new(total_count: Option<usize>) -> Self

Creates counters with a known or unknown total count.

§Parameters
  • total_count - Total work-unit count, or None when unknown.
§Returns

Zeroed counters with the supplied total count.

Source

pub const fn with_total_count(self, total_count: Option<usize>) -> Self

Returns a copy configured with the known or unknown total count.

§Parameters
  • total_count - Total work-unit count, or None when unknown.
§Returns

This counter set with total_count recorded.

Source

pub const fn with_completed_count(self, completed_count: usize) -> Self

Returns a copy configured with the completed count.

§Parameters
  • completed_count - Number of completed work units.
§Returns

This counter set with completed_count recorded.

Source

pub const fn with_active_count(self, active_count: usize) -> Self

Returns a copy configured with the active count.

§Parameters
  • active_count - Number of currently active work units.
§Returns

This counter set with active_count recorded.

Source

pub const fn with_succeeded_count(self, succeeded_count: usize) -> Self

Returns a copy configured with the succeeded count.

§Parameters
  • succeeded_count - Number of successful work units.
§Returns

This counter set with succeeded_count recorded.

Source

pub const fn with_failed_count(self, failed_count: usize) -> Self

Returns a copy configured with the failed count.

§Parameters
  • failed_count - Number of failed work units.
§Returns

This counter set with failed_count recorded.

Source

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.

Source

pub const fn completed_count(&self) -> usize

Returns the completed work-unit count.

§Returns

The number of completed work units.

Source

pub const fn active_count(&self) -> usize

Returns the active work-unit count.

§Returns

The number of currently active work units.

Source

pub const fn succeeded_count(&self) -> usize

Returns the successful work-unit count.

§Returns

The number of successful work units.

Source

pub const fn failed_count(&self) -> usize

Returns the failed work-unit count.

§Returns

The number of failed work units.

Source

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.

Source

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.

Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProgressCounters

Source§

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

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

impl Hash for ProgressCounters

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ProgressCounters

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ProgressCounters

Source§

impl Eq for ProgressCounters

Source§

impl StructuralPartialEq for ProgressCounters

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.