Skip to main content

BatchCallResult

Struct BatchCallResult 

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

Source

pub fn new(outcome: BatchOutcome<E>, values: Vec<Option<R>>) -> Self

Creates a new callable batch result.

§Parameters
  • outcome - Execution outcome and failures.
  • values - Success values indexed by callable position.
§Returns

A callable batch result.

Source

pub const fn outcome(&self) -> &BatchOutcome<E>

Returns the execution outcome for the callable batch.

§Returns

A shared reference to the underlying execution outcome.

Source

pub fn values(&self) -> &[Option<R>]

Returns success values indexed by callable position.

§Returns

A shared slice of optional success values.

Source

pub fn into_outcome(self) -> BatchOutcome<E>

Consumes this result and returns the execution outcome.

§Returns

The underlying execution outcome.

Source

pub fn into_values(self) -> Vec<Option<R>>

Consumes this result and returns success values.

§Returns

Success values indexed by callable position.

Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<R: Debug, E: Debug> Debug for BatchCallResult<R, E>

Source§

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

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

impl<R: PartialEq, E: PartialEq> PartialEq for BatchCallResult<R, E>

Source§

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

Source§

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>

§

impl<R, E> Send for BatchCallResult<R, E>
where R: Send, E: Send,

§

impl<R, E> Sync for BatchCallResult<R, E>
where R: Sync, E: Sync,

§

impl<R, E> Unpin for BatchCallResult<R, E>
where R: Unpin, E: Unpin,

§

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