pub enum BatchExecutionError<E> {
CountShortfall {
expected: usize,
actual: usize,
outcome: BatchOutcome<E>,
},
CountExceeded {
expected: usize,
observed_at_least: usize,
outcome: BatchOutcome<E>,
},
}Expand description
Batch-level error returned when the batch contract is violated.
Task failures are reported through BatchOutcome, not through
this enum. This error is reserved for situations such as declared task-count
mismatches.
use qubit_batch::{
BatchExecutionError,
BatchExecutor,
SequentialBatchExecutor,
};
let error = SequentialBatchExecutor::new()
.for_each_with_count([10, 20], 3, |_value| Ok::<(), &'static str>(()))
.expect_err("iterator should yield fewer items than declared");
assert!(error.is_count_shortfall());
assert_eq!(error.outcome().completed_count(), 2);
match error {
BatchExecutionError::CountShortfall { expected, actual, .. } => {
assert_eq!(expected, 3);
assert_eq!(actual, 2);
}
BatchExecutionError::CountExceeded { .. } => unreachable!(),
}§Type Parameters
E- The task-specific error type stored inside the attached outcome.
Variants§
CountShortfall
The task source ended before the declared task count was reached.
Fields
outcome: BatchOutcome<E>Outcome accumulated from the tasks that did run.
CountExceeded
The task source yielded more tasks than the declared task count.
Implementations§
Source§impl<E> BatchExecutionError<E>
impl<E> BatchExecutionError<E>
Sourcepub const fn outcome(&self) -> &BatchOutcome<E>
pub const fn outcome(&self) -> &BatchOutcome<E>
Returns the batch outcome attached to this error.
§Returns
A shared reference to the attached batch outcome.
Sourcepub fn into_outcome(self) -> BatchOutcome<E>
pub fn into_outcome(self) -> BatchOutcome<E>
Consumes this error and returns the attached batch outcome.
§Returns
The batch outcome accumulated before this error was reported.
Sourcepub const fn is_count_shortfall(&self) -> bool
pub const fn is_count_shortfall(&self) -> bool
Returns whether this error represents a task-count shortfall.
§Returns
true if this error is Self::CountShortfall.
Sourcepub const fn is_count_exceeded(&self) -> bool
pub const fn is_count_exceeded(&self) -> bool
Returns whether this error represents an oversized task source.
§Returns
true if this error is Self::CountExceeded.
Trait Implementations§
Source§impl<E: Clone> Clone for BatchExecutionError<E>
impl<E: Clone> Clone for BatchExecutionError<E>
Source§fn clone(&self) -> BatchExecutionError<E>
fn clone(&self) -> BatchExecutionError<E>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<E: Debug> Debug for BatchExecutionError<E>
impl<E: Debug> Debug for BatchExecutionError<E>
Source§impl<E> Display for BatchExecutionError<E>
impl<E> Display for BatchExecutionError<E>
Source§impl<E> Error for BatchExecutionError<E>
impl<E> Error for BatchExecutionError<E>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<E: PartialEq> PartialEq for BatchExecutionError<E>
impl<E: PartialEq> PartialEq for BatchExecutionError<E>
Source§fn eq(&self, other: &BatchExecutionError<E>) -> bool
fn eq(&self, other: &BatchExecutionError<E>) -> bool
self and other values to be equal, and is used by ==.