Skip to main content

Operation

Struct Operation 

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

Unique identifier for this operation

§operation_type: OperationType

The type of operation (Step, Wait, Callback, etc.)

§status: OperationStatus

Current 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

Source

pub fn new( operation_id: impl Into<String>, operation_type: OperationType, ) -> Operation

Creates a new Operation with the given ID and type.

Source

pub fn with_parent_id(self, parent_id: impl Into<String>) -> Operation

Sets the parent ID for this operation.

Source

pub fn with_name(self, name: impl Into<String>) -> Operation

Sets the name for this operation.

Source

pub fn with_sub_type(self, sub_type: impl Into<String>) -> Operation

Sets the sub-type for this operation. Requirements: 23.3, 23.4

Source

pub fn is_completed(&self) -> bool

Returns true if the operation has completed (succeeded or failed).

Source

pub fn is_succeeded(&self) -> bool

Returns true if the operation succeeded.

Source

pub fn is_failed(&self) -> bool

Returns true if the operation failed.

Source

pub fn get_result(&self) -> Option<&str>

Gets the result from the appropriate details field based on operation type.

Source

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.

Source

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 Clone for Operation

Source§

fn clone(&self) -> Operation

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Operation

Source§

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

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

impl<'de> Deserialize<'de> for Operation

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Operation, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Operation

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<B> IntoFunctionResponse<B, Body> for B
where B: Serialize,

Source§

fn into_response(self) -> FunctionResponse<B, Body>

Convert the type into a FunctionResponse.
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DurableValue for T