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
impl ProgressEventBuilder
Sourcepub const fn new() -> Self
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.
Sourcepub const fn phase(self, phase: ProgressPhase) -> Self
pub const fn phase(self, phase: ProgressPhase) -> Self
Sourcepub const fn counters(self, counters: ProgressCounters) -> Self
pub const fn counters(self, counters: ProgressCounters) -> Self
Sourcepub const fn unknown_total(self) -> Self
pub const fn unknown_total(self) -> Self
Sourcepub const fn failed_count(self, failed_count: usize) -> Self
pub const fn failed_count(self, failed_count: usize) -> Self
Sourcepub fn stage(self, stage: ProgressStage) -> Self
pub fn stage(self, stage: ProgressStage) -> Self
Sourcepub fn stage_named(self, id: &str, name: &str) -> Self
pub fn stage_named(self, id: &str, name: &str) -> Self
Sourcepub fn build(self) -> ProgressEvent
pub fn build(self) -> ProgressEvent
Trait Implementations§
Source§impl Clone for ProgressEventBuilder
impl Clone for ProgressEventBuilder
Source§fn clone(&self) -> ProgressEventBuilder
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ProgressEventBuilder
impl Debug for ProgressEventBuilder
Source§impl Default for ProgressEventBuilder
impl Default for ProgressEventBuilder
Source§impl PartialEq for ProgressEventBuilder
impl PartialEq for ProgressEventBuilder
Source§fn eq(&self, other: &ProgressEventBuilder) -> bool
fn eq(&self, other: &ProgressEventBuilder) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ProgressEventBuilder
Auto Trait Implementations§
impl Freeze for ProgressEventBuilder
impl RefUnwindSafe for ProgressEventBuilder
impl Send for ProgressEventBuilder
impl Sync for ProgressEventBuilder
impl Unpin for ProgressEventBuilder
impl UnsafeUnpin for ProgressEventBuilder
impl UnwindSafe for ProgressEventBuilder
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