pub struct BatchResult<T> {
pub items: Vec<BatchItem<T>>,
pub completion_reason: CompletionReason,
}Expand description
Result of a batch operation (map or parallel).
Contains results for all items and the reason for completion.
§Examples
use durable_execution_sdk::concurrency::{BatchResult, BatchItem, CompletionReason};
// Create a batch result with some items
let items = vec![
BatchItem::succeeded(0, "first"),
BatchItem::succeeded(1, "second"),
BatchItem::failed(2, durable_execution_sdk::ErrorObject::new("Error", "Failed")),
];
let result = BatchResult::new(items, CompletionReason::AllCompleted);
assert_eq!(result.success_count(), 2);
assert_eq!(result.failure_count(), 1);
assert_eq!(result.total_count(), 3);
assert!(!result.all_succeeded());
assert!(result.has_failures());Fields§
§items: Vec<BatchItem<T>>Results for each item in the batch
completion_reason: CompletionReasonReason why the batch completed
Implementations§
Source§impl<T> BatchResult<T>
impl<T> BatchResult<T>
Sourcepub fn new(
items: Vec<BatchItem<T>>,
completion_reason: CompletionReason,
) -> Self
pub fn new( items: Vec<BatchItem<T>>, completion_reason: CompletionReason, ) -> Self
Creates a new BatchResult.
Sourcepub fn get_results(&self) -> Result<Vec<&T>, DurableError>
pub fn get_results(&self) -> Result<Vec<&T>, DurableError>
Returns all results from succeeded items.
Returns an error if any item failed and the completion reason indicates failure tolerance was exceeded.
Sourcepub fn success_count(&self) -> usize
pub fn success_count(&self) -> usize
Returns the number of succeeded items.
Sourcepub fn failure_count(&self) -> usize
pub fn failure_count(&self) -> usize
Returns the number of failed items.
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Returns the total number of items.
Sourcepub fn all_succeeded(&self) -> bool
pub fn all_succeeded(&self) -> bool
Returns true if all items succeeded.
Sourcepub fn has_failures(&self) -> bool
pub fn has_failures(&self) -> bool
Returns true if any item failed.
Sourcepub fn is_failure(&self) -> bool
pub fn is_failure(&self) -> bool
Returns true if the batch completed due to failure tolerance being exceeded.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true if the batch completed successfully (min successful reached or all completed).
Trait Implementations§
Source§impl<T: Clone> Clone for BatchResult<T>
impl<T: Clone> Clone for BatchResult<T>
Source§fn clone(&self) -> BatchResult<T>
fn clone(&self) -> BatchResult<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for BatchResult<T>
impl<T: Debug> Debug for BatchResult<T>
Source§impl<T> Default for BatchResult<T>
impl<T> Default for BatchResult<T>
Source§impl<'de, T> Deserialize<'de> for BatchResult<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for BatchResult<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> Freeze for BatchResult<T>
impl<T> RefUnwindSafe for BatchResult<T>where
T: RefUnwindSafe,
impl<T> Send for BatchResult<T>where
T: Send,
impl<T> Sync for BatchResult<T>where
T: Sync,
impl<T> Unpin for BatchResult<T>where
T: Unpin,
impl<T> UnsafeUnpin for BatchResult<T>
impl<T> UnwindSafe for BatchResult<T>where
T: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<B> IntoFunctionResponse<B, Body> for Bwhere
B: Serialize,
impl<B> IntoFunctionResponse<B, Body> for Bwhere
B: Serialize,
Source§fn into_response(self) -> FunctionResponse<B, Body>
fn into_response(self) -> FunctionResponse<B, Body>
Convert the type into a FunctionResponse.
Creates a shared type from an unshared type.