Skip to main content

ProgressEventBuilder

Struct ProgressEventBuilder 

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

Builder for ProgressEvent.

The builder keeps the common path compact by letting callers configure phase, counters, optional stage information, and elapsed time in a single chain.

§Examples

use std::time::Duration;

use qubit_progress::{
    ProgressEvent,
    ProgressPhase,
};

let event = ProgressEvent::builder()
    .running()
    .total(8)
    .completed(3)
    .active(1)
    .stage_named("copy", "Copy files")
    .elapsed(Duration::from_secs(2))
    .build();

assert_eq!(event.phase(), ProgressPhase::Running);
assert_eq!(event.counters().completed_count(), 3);
assert_eq!(event.stage().map(|stage| stage.id()), Some("copy"));

Implementations§

Source§

impl ProgressEventBuilder

Source

pub const fn new() -> Self

Creates a builder with default running progress state.

§Returns

A builder whose phase is ProgressPhase::Running, elapsed duration is zero, total count is unknown, and all counters are zero.

Source

pub const fn phase(self, phase: ProgressPhase) -> Self

Configures the lifecycle phase.

§Parameters
  • phase - Lifecycle phase to report.
§Returns

This builder with phase recorded.

Source

pub const fn started(self) -> Self

Configures the event as started.

§Returns

This builder with ProgressPhase::Started.

Source

pub const fn running(self) -> Self

Configures the event as running.

§Returns

This builder with ProgressPhase::Running.

Source

pub const fn finished(self) -> Self

Configures the event as finished.

§Returns

This builder with ProgressPhase::Finished.

Source

pub const fn failed(self) -> Self

Configures the event as failed.

§Returns

This builder with ProgressPhase::Failed.

Source

pub const fn canceled(self) -> Self

Configures the event as canceled.

§Returns

This builder with ProgressPhase::Canceled.

Source

pub const fn counters(self, counters: ProgressCounters) -> Self

Replaces the current counter set.

§Parameters
  • counters - Complete counter set to carry in the built event.
§Returns

This builder with counters recorded.

Source

pub const fn total(self, total_count: usize) -> Self

Configures a known total work-unit count.

§Parameters
  • total_count - Total number of work units.
§Returns

This builder with a known total count.

Source

pub const fn unknown_total(self) -> Self

Configures the event as unknown-total progress.

§Returns

This builder with no total count.

Source

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

Configures the completed work-unit count.

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

This builder with completed_count recorded.

Source

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

Configures the active work-unit count.

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

This builder with active_count recorded.

Source

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

Configures the successful work-unit count.

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

This builder with succeeded_count recorded.

Source

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

Configures the failed work-unit count.

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

This builder with failed_count recorded.

Source

pub fn stage(self, stage: ProgressStage) -> Self

Configures the current stage.

§Parameters
  • stage - Stage metadata to carry in the built event.
§Returns

This builder with stage recorded.

Source

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

Configures the current stage from an id and display name.

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

This builder with a stage created from id and name.

Source

pub const fn elapsed(self, elapsed: Duration) -> Self

Configures the elapsed duration.

§Parameters
  • elapsed - Monotonic elapsed duration to carry in the event.
§Returns

This builder with elapsed recorded.

Source

pub fn build(self) -> ProgressEvent

Builds the progress event.

§Returns

An immutable ProgressEvent with the configured values.

Trait Implementations§

Source§

impl Clone for ProgressEventBuilder

Source§

fn clone(&self) -> ProgressEventBuilder

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 ProgressEventBuilder

Source§

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

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

impl Default for ProgressEventBuilder

Source§

fn default() -> Self

Creates a builder with default running progress state.

§Returns

A builder equivalent to Self::new.

Source§

impl PartialEq for ProgressEventBuilder

Source§

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

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.