Skip to main content

Module traits

Module traits 

Source
Expand description

Trait aliases for common bounds in the AWS Durable Execution SDK.

This module provides trait aliases that simplify common trait bound combinations used throughout the SDK. These aliases make function signatures more readable and maintainable while preserving full type safety.

§Overview

The SDK frequently requires types to implement multiple traits for serialization, thread safety, and lifetime requirements. Instead of repeating these bounds everywhere, this module provides convenient trait aliases.

§Available Trait Aliases

  • DurableValue: For values that can be durably stored and retrieved
  • StepFn: For step function closures

§Example

use durable_execution_sdk::traits::{DurableValue, StepFn};
use durable_execution_sdk::handlers::StepContext;
use durable_execution_sdk::DurableError;

// Using DurableValue in a generic function
fn process_value<T: DurableValue>(value: T) -> String {
    // T is guaranteed to be Serialize + DeserializeOwned + Send + Sync + 'static
    serde_json::to_string(&value).unwrap_or_default()
}

// Using StepFn for step function bounds
fn execute_step<T, F>(func: F) -> Result<T, DurableError>
where
    T: DurableValue,
    F: StepFn<T>,
{
    // F is guaranteed to be FnOnce(StepContext) -> Result<T, Box<dyn Error + Send + Sync>> + Send
    todo!()
}

Traits§

DurableValue
Trait alias for values that can be durably stored and retrieved.
StepFn
Trait alias for step function bounds.