pub struct BatchCallResult<R, E> { /* private fields */ }Expand description
Result produced by crate::BatchExecutor::call.
The execution outcome contains the same failure aggregation as
crate::BatchExecutor::execute. The value list is indexed by the original
callable index; successful callables store Some(value), while failed or
panicked callables store None.
use qubit_batch::{
BatchExecutor,
SequentialBatchExecutor,
};
fn count_users() -> Result<usize, &'static str> {
Ok(3)
}
fn count_orders() -> Result<usize, &'static str> {
Ok(5)
}
let result = SequentialBatchExecutor::new()
.call([count_users, count_orders])
.expect("array length should be exact");
assert!(result.outcome().is_success());
assert_eq!(result.values(), &[Some(3), Some(5)]);§Type Parameters
R- Callable success value type.E- Callable error type.
Implementations§
Source§impl<R, E> BatchCallResult<R, E>
impl<R, E> BatchCallResult<R, E>
Sourcepub fn new(outcome: BatchOutcome<E>, values: Vec<Option<R>>) -> Self
pub fn new(outcome: BatchOutcome<E>, values: Vec<Option<R>>) -> Self
Sourcepub const fn outcome(&self) -> &BatchOutcome<E>
pub const fn outcome(&self) -> &BatchOutcome<E>
Returns the execution outcome for the callable batch.
§Returns
A shared reference to the underlying execution outcome.
Sourcepub fn values(&self) -> &[Option<R>]
pub fn values(&self) -> &[Option<R>]
Returns success values indexed by callable position.
§Returns
A shared slice of optional success values.
Sourcepub fn into_outcome(self) -> BatchOutcome<E>
pub fn into_outcome(self) -> BatchOutcome<E>
Sourcepub fn into_values(self) -> Vec<Option<R>>
pub fn into_values(self) -> Vec<Option<R>>
Consumes this result and returns success values.
§Returns
Success values indexed by callable position.
Sourcepub fn into_parts(self) -> (BatchOutcome<E>, Vec<Option<R>>)
pub fn into_parts(self) -> (BatchOutcome<E>, Vec<Option<R>>)
Consumes this result and returns both stored parts.
§Returns
A tuple containing the execution outcome and indexed success values.
Trait Implementations§
Source§impl<R: Clone, E: Clone> Clone for BatchCallResult<R, E>
impl<R: Clone, E: Clone> Clone for BatchCallResult<R, E>
Source§fn clone(&self) -> BatchCallResult<R, E>
fn clone(&self) -> BatchCallResult<R, 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<R: PartialEq, E: PartialEq> PartialEq for BatchCallResult<R, E>
impl<R: PartialEq, E: PartialEq> PartialEq for BatchCallResult<R, E>
Source§fn eq(&self, other: &BatchCallResult<R, E>) -> bool
fn eq(&self, other: &BatchCallResult<R, E>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<R: Eq, E: Eq> Eq for BatchCallResult<R, E>
impl<R, E> StructuralPartialEq for BatchCallResult<R, E>
Auto Trait Implementations§
impl<R, E> Freeze for BatchCallResult<R, E>
impl<R, E> RefUnwindSafe for BatchCallResult<R, E>where
R: RefUnwindSafe,
E: RefUnwindSafe,
impl<R, E> Send for BatchCallResult<R, E>
impl<R, E> Sync for BatchCallResult<R, E>
impl<R, E> Unpin for BatchCallResult<R, E>
impl<R, E> UnsafeUnpin for BatchCallResult<R, E>
impl<R, E> UnwindSafe for BatchCallResult<R, E>where
R: UnwindSafe,
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