Skip to main content

ProgressStage

Struct ProgressStage 

Source
pub struct ProgressStage { /* private fields */ }
Expand description

Describes the current stage of a multi-stage operation.

§Examples

use qubit_progress::ProgressStage;

let stage = ProgressStage::new("verify", "Verify files")
    .with_index(2)
    .with_total_stages(4)
    .with_weight(0.25);

assert_eq!(stage.id(), "verify");
assert_eq!(stage.name(), "Verify files");
assert_eq!(stage.index(), Some(2));

Implementations§

Source§

impl ProgressStage

Source

pub fn new(id: &str, name: &str) -> Self

Creates a stage with a stable id and display name.

§Parameters
  • id - Stable machine-readable identifier.
  • name - Human-readable stage name.
§Returns

A stage with no index, total stage count, or weight.

Source

pub const fn with_index(self, index: usize) -> Self

Returns a copy configured with a zero-based stage index.

§Parameters
  • index - Zero-based stage index.
§Returns

This stage with index recorded.

Source

pub const fn with_total_stages(self, total_stages: usize) -> Self

Returns a copy configured with the total stage count.

§Parameters
  • total_stages - Total number of stages in the operation.
§Returns

This stage with total_stages recorded.

Source

pub const fn with_weight(self, weight: f64) -> Self

Returns a copy configured with a relative stage weight.

The weight is intended for caller-side weighted progress calculations. Callers should supply finite, non-negative values. This method records the supplied value as-is and does not validate NaN, infinity, or negative input.

§Parameters
  • weight - Finite, non-negative relative stage weight used by callers that compute weighted total progress.
§Returns

This stage with weight recorded.

Source

pub fn id(&self) -> &str

Returns the stable stage identifier.

§Returns

The machine-readable stage id.

Source

pub fn name(&self) -> &str

Returns the human-readable stage name.

§Returns

The display name for this stage.

Source

pub const fn index(&self) -> Option<usize>

Returns the stage index when known.

§Returns

Some(index) when a zero-based stage index was supplied, otherwise None.

Source

pub const fn total_stages(&self) -> Option<usize>

Returns the total stage count when known.

§Returns

Some(total) when a total stage count was supplied, otherwise None.

Source

pub const fn weight(&self) -> Option<f64>

Returns the relative stage weight when known.

§Returns

Some(weight) when a weight was supplied, otherwise None.

Trait Implementations§

Source§

impl Clone for ProgressStage

Source§

fn clone(&self) -> ProgressStage

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 ProgressStage

Source§

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

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

impl PartialEq for ProgressStage

Source§

fn eq(&self, other: &ProgressStage) -> 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 StructuralPartialEq for ProgressStage

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.