pub struct DurableOperation { /* private fields */ }Expand description
A durable operation with inspection and interaction methods.
Wraps an SDK Operation and provides type-specific inspection methods
and callback interaction capabilities for testing.
§Examples
use durable_execution_sdk_testing::DurableOperation;
// Get operation from test runner
let op = runner.get_operation("my-step").unwrap();
// Inspect basic properties
println!("ID: {}", op.get_id());
println!("Type: {}", op.get_type());
println!("Status: {}", op.get_status());
// Get type-specific details
if op.get_type() == OperationType::Step {
let details = op.get_step_details::<String>().unwrap();
println!("Result: {:?}", details.result);
}Implementations§
Source§impl DurableOperation
impl DurableOperation
Sourcepub fn new(operation: Operation) -> Self
pub fn new(operation: Operation) -> Self
Creates a new DurableOperation wrapping the given SDK operation.
Sourcepub fn with_callback_sender(
operation: Operation,
callback_sender: Arc<dyn CallbackSender>,
) -> Self
pub fn with_callback_sender( operation: Operation, callback_sender: Arc<dyn CallbackSender>, ) -> Self
Creates a new DurableOperation with a callback sender.
Sourcepub fn with_status_watcher(
operation: Operation,
status_watcher: Receiver<OperationStatus>,
) -> Self
pub fn with_status_watcher( operation: Operation, status_watcher: Receiver<OperationStatus>, ) -> Self
Creates a new DurableOperation with a status watcher.
Sourcepub fn with_all(
operation: Operation,
callback_sender: Option<Arc<dyn CallbackSender>>,
status_watcher: Option<Receiver<OperationStatus>>,
) -> Self
pub fn with_all( operation: Operation, callback_sender: Option<Arc<dyn CallbackSender>>, status_watcher: Option<Receiver<OperationStatus>>, ) -> Self
Creates a new DurableOperation with both callback sender and status watcher.
Sourcepub fn get_parent_id(&self) -> Option<&str>
pub fn get_parent_id(&self) -> Option<&str>
Gets the parent operation ID.
§Returns
The parent operation ID if this is a nested operation, None otherwise.
Sourcepub fn get_type(&self) -> OperationType
pub fn get_type(&self) -> OperationType
Gets the operation type.
§Returns
The type of operation (Step, Wait, Callback, Invoke, Context, Execution).
Sourcepub fn get_status(&self) -> OperationStatus
pub fn get_status(&self) -> OperationStatus
Sourcepub fn get_start_timestamp(&self) -> Option<DateTime<Utc>>
pub fn get_start_timestamp(&self) -> Option<DateTime<Utc>>
Sourcepub fn get_end_timestamp(&self) -> Option<DateTime<Utc>>
pub fn get_end_timestamp(&self) -> Option<DateTime<Utc>>
Sourcepub fn get_operation_data(&self) -> &Operation
pub fn get_operation_data(&self) -> &Operation
Sourcepub fn is_callback(&self) -> bool
pub fn is_callback(&self) -> bool
Sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
Checks if the operation has completed.
§Returns
True if the operation status is terminal (Succeeded, Failed, Cancelled, TimedOut, Stopped).
Sourcepub fn is_succeeded(&self) -> bool
pub fn is_succeeded(&self) -> bool
Sourcepub fn is_failed(&self) -> bool
pub fn is_failed(&self) -> bool
Checks if the operation failed.
§Returns
True if the operation status is Failed, Cancelled, or TimedOut.
Sourcepub fn with_operations(self, all_operations: Arc<Vec<Operation>>) -> Self
pub fn with_operations(self, all_operations: Arc<Vec<Operation>>) -> Self
Sets the shared reference to all operations for child enumeration.
Source§impl DurableOperation
impl DurableOperation
Sourcepub fn get_child_operations(&self) -> Vec<DurableOperation>
pub fn get_child_operations(&self) -> Vec<DurableOperation>
Returns all child operations nested under this operation.
Child operations are those whose parent_id matches this operation’s id.
The returned operations are ordered by their position in the operations list.
§Returns
A vector of DurableOperation instances representing child operations.
Returns an empty vector if no children exist or if the operations list
is not available.
Source§impl DurableOperation
impl DurableOperation
Sourcepub fn get_step_details<T: DeserializeOwned>(
&self,
) -> Result<StepDetails<T>, TestError>
pub fn get_step_details<T: DeserializeOwned>( &self, ) -> Result<StepDetails<T>, TestError>
Sourcepub fn get_wait_details(&self) -> Result<WaitDetails, TestError>
pub fn get_wait_details(&self) -> Result<WaitDetails, TestError>
Gets wait-specific details.
§Returns
Ok(WaitDetails)- The wait details if this is a Wait operationErr(TestError)- Error if this is not a Wait operation
Sourcepub fn get_callback_details<T: DeserializeOwned>(
&self,
) -> Result<CallbackDetails<T>, TestError>
pub fn get_callback_details<T: DeserializeOwned>( &self, ) -> Result<CallbackDetails<T>, TestError>
Sourcepub fn get_invoke_details<T: DeserializeOwned>(
&self,
) -> Result<InvokeDetails<T>, TestError>
pub fn get_invoke_details<T: DeserializeOwned>( &self, ) -> Result<InvokeDetails<T>, TestError>
Sourcepub fn get_context_details<T: DeserializeOwned>(
&self,
) -> Result<ContextDetails<T>, TestError>
pub fn get_context_details<T: DeserializeOwned>( &self, ) -> Result<ContextDetails<T>, TestError>
Source§impl DurableOperation
impl DurableOperation
Sourcepub async fn send_callback_failure(
&self,
error: &TestResultError,
) -> Result<(), TestError>
pub async fn send_callback_failure( &self, error: &TestResultError, ) -> Result<(), TestError>
Source§impl DurableOperation
impl DurableOperation
Sourcepub async fn wait_for_data(
&self,
target_status: WaitingOperationStatus,
) -> Result<&Self, TestError>
pub async fn wait_for_data( &self, target_status: WaitingOperationStatus, ) -> Result<&Self, TestError>
Trait Implementations§
Source§impl Clone for DurableOperation
impl Clone for DurableOperation
Auto Trait Implementations§
impl Freeze for DurableOperation
impl !RefUnwindSafe for DurableOperation
impl Send for DurableOperation
impl Sync for DurableOperation
impl Unpin for DurableOperation
impl UnsafeUnpin for DurableOperation
impl !UnwindSafe for DurableOperation
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