Skip to main content

BatchOutcomeBuilder

Struct BatchOutcomeBuilder 

Source
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>

Source

pub fn builder(task_count: usize) -> Self

Starts building a batch outcome.

§Parameters
  • task_count - Declared task count for the batch.
§Returns

A builder initialized with zero counters, zero elapsed time, and no failures.

Source

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

Sets the number of tasks that finished.

§Parameters
  • completed_count - Number of tasks that reached a terminal outcome.
§Returns

The updated builder.

Source

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

Sets the number of successful tasks.

§Parameters
  • succeeded_count - Number of tasks that completed successfully.
§Returns

The updated builder.

Source

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

Sets the number of tasks that returned their own error.

§Parameters
  • failed_count - Number of tasks that failed with task errors.
§Returns

The updated builder.

Source

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

Sets the number of tasks that panicked.

§Parameters
  • panicked_count - Number of tasks that panicked.
§Returns

The updated builder.

Source

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

Sets the total monotonic elapsed duration.

§Parameters
  • elapsed - Total monotonic elapsed duration.
§Returns

The updated builder.

Source

pub fn failures(self, failures: Vec<BatchTaskFailure<E>>) -> Self

Sets the detailed failure records.

§Parameters
  • failures - Detailed task failure records.
§Returns

The updated builder.

Source

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.

Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<E: Debug> Debug for BatchOutcomeBuilder<E>

Source§

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

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

impl<E: PartialEq> PartialEq for BatchOutcomeBuilder<E>

Source§

fn eq(&self, other: &BatchOutcomeBuilder<E>) -> 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<E: Eq> Eq for BatchOutcomeBuilder<E>

Source§

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> 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.