pub struct BatchItem<T> {
pub index: usize,
pub status: BatchItemStatus,
pub result: Option<T>,
pub error: Option<ErrorObject>,
}Expand description
Result of a single item in a batch operation.
Contains the status, optional result value, and optional error for each item processed in a map or parallel operation.
§Examples
use durable_execution_sdk::concurrency::{BatchItem, BatchItemStatus};
use durable_execution_sdk::ErrorObject;
// Succeeded item
let success = BatchItem::succeeded(0, 42);
assert!(success.is_succeeded());
assert_eq!(success.get_result(), Some(&42));
// Failed item
let error = ErrorObject::new("TestError", "Something went wrong");
let failure = BatchItem::<i32>::failed(1, error);
assert!(failure.is_failed());
assert!(failure.get_error().is_some());
// Pending item
let pending = BatchItem::<i32>::pending(2);
assert_eq!(pending.status, BatchItemStatus::Pending);Fields§
§index: usizeIndex of this item in the original collection
status: BatchItemStatusStatus of this item
result: Option<T>Result value if succeeded
error: Option<ErrorObject>Error details if failed
Implementations§
Source§impl<T> BatchItem<T>
impl<T> BatchItem<T>
Sourcepub fn failed(index: usize, error: ErrorObject) -> Self
pub fn failed(index: usize, error: ErrorObject) -> Self
Creates a new failed BatchItem.
Sourcepub fn is_succeeded(&self) -> bool
pub fn is_succeeded(&self) -> bool
Returns true if this item succeeded.
Sourcepub fn get_result(&self) -> Option<&T>
pub fn get_result(&self) -> Option<&T>
Returns a reference to the result if succeeded.
Sourcepub fn get_error(&self) -> Option<&ErrorObject>
pub fn get_error(&self) -> Option<&ErrorObject>
Returns a reference to the error if failed.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for BatchItem<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for BatchItem<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 BatchItem<T>where
T: Freeze,
impl<T> RefUnwindSafe for BatchItem<T>where
T: RefUnwindSafe,
impl<T> Send for BatchItem<T>where
T: Send,
impl<T> Sync for BatchItem<T>where
T: Sync,
impl<T> Unpin for BatchItem<T>where
T: Unpin,
impl<T> UnsafeUnpin for BatchItem<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for BatchItem<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.