pub struct BatchOutcomeBuilder<E> { /* private fields */ }Expand description
Builder carrying validated parts for a crate::BatchOutcome.
The builder checks aggregate counters, failure detail count, duplicate indexes, and failed-versus-panicked detail counts before creating an outcome.
use qubit_batch::{
BatchOutcomeBuilder,
BatchTaskError,
BatchTaskFailure,
};
let outcome = BatchOutcomeBuilder::builder(2)
.completed_count(2)
.succeeded_count(1)
.failed_count(1)
.failures(vec![BatchTaskFailure::new(
1,
BatchTaskError::Failed("invalid row"),
)])
.build()
.expect("outcome counters should match failure details");
assert_eq!(outcome.failed_count(), 1);
assert_eq!(outcome.failures()[0].index(), 1);Implementations§
Source§impl<E> BatchOutcomeBuilder<E>
impl<E> BatchOutcomeBuilder<E>
Sourcepub const fn completed_count(self, completed_count: usize) -> Self
pub const fn completed_count(self, completed_count: usize) -> Self
Sourcepub const fn succeeded_count(self, succeeded_count: usize) -> Self
pub const fn succeeded_count(self, succeeded_count: usize) -> Self
Sourcepub const fn failed_count(self, failed_count: usize) -> Self
pub const fn failed_count(self, failed_count: usize) -> Self
Sourcepub const fn panicked_count(self, panicked_count: usize) -> Self
pub const fn panicked_count(self, panicked_count: usize) -> Self
Sourcepub fn failures(self, failures: Vec<BatchTaskFailure<E>>) -> Self
pub fn failures(self, failures: Vec<BatchTaskFailure<E>>) -> Self
Sourcepub fn validate(self) -> Result<Self, BatchOutcomeBuildError>
pub fn validate(self) -> Result<Self, BatchOutcomeBuildError>
Validates this builder and sorts failure records by task index.
§Returns
Ok(builder) when the counters and failure details are consistent.
§Errors
Returns BatchOutcomeBuildError when the counters or failure details
are inconsistent.
Sourcepub fn build(self) -> Result<BatchOutcome<E>, BatchOutcomeBuildError>
pub fn build(self) -> Result<BatchOutcome<E>, BatchOutcomeBuildError>
Validates this builder and creates a batch outcome.
§Returns
Ok(outcome) when the counters and failure details are consistent.
§Errors
Returns BatchOutcomeBuildError when the counters or failure details
are inconsistent.
Trait Implementations§
Source§impl<E: Clone> Clone for BatchOutcomeBuilder<E>
impl<E: Clone> Clone for BatchOutcomeBuilder<E>
Source§fn clone(&self) -> BatchOutcomeBuilder<E>
fn clone(&self) -> BatchOutcomeBuilder<E>
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<E: Debug> Debug for BatchOutcomeBuilder<E>
impl<E: Debug> Debug for BatchOutcomeBuilder<E>
Source§impl<E: PartialEq> PartialEq for BatchOutcomeBuilder<E>
impl<E: PartialEq> PartialEq for BatchOutcomeBuilder<E>
Source§fn eq(&self, other: &BatchOutcomeBuilder<E>) -> bool
fn eq(&self, other: &BatchOutcomeBuilder<E>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<E: Eq> Eq for BatchOutcomeBuilder<E>
impl<E> StructuralPartialEq for BatchOutcomeBuilder<E>
Auto Trait Implementations§
impl<E> Freeze for BatchOutcomeBuilder<E>
impl<E> RefUnwindSafe for BatchOutcomeBuilder<E>where
E: RefUnwindSafe,
impl<E> Send for BatchOutcomeBuilder<E>where
E: Send,
impl<E> Sync for BatchOutcomeBuilder<E>where
E: Sync,
impl<E> Unpin for BatchOutcomeBuilder<E>where
E: Unpin,
impl<E> UnsafeUnpin for BatchOutcomeBuilder<E>
impl<E> UnwindSafe for BatchOutcomeBuilder<E>where
E: UnwindSafe,
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