pub struct Operation {Show 16 fields
pub operation_id: String,
pub operation_type: OperationType,
pub status: OperationStatus,
pub result: Option<String>,
pub error: Option<ErrorObject>,
pub parent_id: Option<String>,
pub name: Option<String>,
pub sub_type: Option<String>,
pub start_timestamp: Option<i64>,
pub end_timestamp: Option<i64>,
pub execution_details: Option<ExecutionDetails>,
pub step_details: Option<StepDetails>,
pub wait_details: Option<WaitDetails>,
pub callback_details: Option<CallbackDetails>,
pub chained_invoke_details: Option<ChainedInvokeDetails>,
pub context_details: Option<ContextDetails>,
}Expand description
Represents a checkpointed operation in a durable execution.
Operations are the fundamental unit of state in durable executions. Each operation has a unique ID and tracks its type, status, and result.
§Examples
Creating a new operation:
use durable_execution_sdk::operation::{Operation, OperationType, OperationStatus};
let op = Operation::new("step-001", OperationType::Step);
assert_eq!(op.operation_id, "step-001");
assert_eq!(op.operation_type, OperationType::Step);
assert_eq!(op.status, OperationStatus::Started);Serializing and deserializing operations:
use durable_execution_sdk::operation::{Operation, OperationType, OperationStatus};
let mut op = Operation::new("wait-001", OperationType::Wait);
op.status = OperationStatus::Succeeded;
op.result = Some("done".to_string());
let json = serde_json::to_string(&op).unwrap();
let restored: Operation = serde_json::from_str(&json).unwrap();
assert_eq!(restored.operation_id, "wait-001");
assert_eq!(restored.status, OperationStatus::Succeeded);Fields§
§operation_id: StringUnique identifier for this operation
operation_type: OperationTypeThe type of operation (Step, Wait, Callback, etc.)
status: OperationStatusCurrent status of the operation
result: Option<String>Serialized result if the operation succeeded (legacy field, prefer type-specific details)
error: Option<ErrorObject>Error details if the operation failed
parent_id: Option<String>Parent operation ID for nested operations
name: Option<String>Optional human-readable name for the operation
sub_type: Option<String>SDK-level categorization of the operation (e.g., “map”, “parallel”, “wait_for_condition”) Requirements: 23.3, 23.4
start_timestamp: Option<i64>Start timestamp of the operation (milliseconds since epoch)
end_timestamp: Option<i64>End timestamp of the operation (milliseconds since epoch)
execution_details: Option<ExecutionDetails>Execution details for EXECUTION type operations
step_details: Option<StepDetails>Step details for STEP type operations
wait_details: Option<WaitDetails>Wait details for WAIT type operations
callback_details: Option<CallbackDetails>Callback details for CALLBACK type operations
chained_invoke_details: Option<ChainedInvokeDetails>Chained invoke details for CHAINED_INVOKE type operations
context_details: Option<ContextDetails>Context details for CONTEXT type operations
Implementations§
Source§impl Operation
impl Operation
Sourcepub fn new(
operation_id: impl Into<String>,
operation_type: OperationType,
) -> Operation
pub fn new( operation_id: impl Into<String>, operation_type: OperationType, ) -> Operation
Creates a new Operation with the given ID and type.
Sourcepub fn with_parent_id(self, parent_id: impl Into<String>) -> Operation
pub fn with_parent_id(self, parent_id: impl Into<String>) -> Operation
Sets the parent ID for this operation.
Sourcepub fn with_sub_type(self, sub_type: impl Into<String>) -> Operation
pub fn with_sub_type(self, sub_type: impl Into<String>) -> Operation
Sets the sub-type for this operation. Requirements: 23.3, 23.4
Sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
Returns true if the operation has completed (succeeded or failed).
Sourcepub fn is_succeeded(&self) -> bool
pub fn is_succeeded(&self) -> bool
Returns true if the operation succeeded.
Sourcepub fn get_result(&self) -> Option<&str>
pub fn get_result(&self) -> Option<&str>
Gets the result from the appropriate details field based on operation type.
Sourcepub fn get_retry_payload(&self) -> Option<&str>
pub fn get_retry_payload(&self) -> Option<&str>
Gets the retry payload from StepDetails for STEP operations.
This is used for the wait-for-condition pattern where state is passed between retry attempts via the Payload field.
§Returns
The payload string if this is a STEP operation with a payload, None otherwise.
Sourcepub fn get_attempt(&self) -> Option<u32>
pub fn get_attempt(&self) -> Option<u32>
Gets the current attempt number from StepDetails for STEP operations.
§Returns
The attempt number (0-indexed) if this is a STEP operation with attempt tracking, None otherwise.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Operation
impl<'de> Deserialize<'de> for Operation
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Operation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Operation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Operation
impl Serialize for Operation
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Operation
impl RefUnwindSafe for Operation
impl Send for Operation
impl Sync for Operation
impl Unpin for Operation
impl UnsafeUnpin for Operation
impl UnwindSafe for Operation
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
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>
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>
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 more