Skip to main content

DurableValue

Trait DurableValue 

Source
pub trait DurableValue:
    Serialize
    + DeserializeOwned
    + Send { }
Expand description

Trait alias for values that can be durably stored and retrieved.

This trait combines the necessary bounds for serialization, deserialization, and thread-safe sending across async boundaries. Any type implementing DurableValue can be:

  • Serialized to JSON for checkpointing
  • Deserialized from JSON during replay
  • Safely sent between threads

§Equivalent Bounds

DurableValue is equivalent to:

Serialize + DeserializeOwned + Send

§Blanket Implementation

This trait is automatically implemented for all types that satisfy the bounds. You don’t need to implement it manually.

§Example

use durable_execution_sdk::traits::DurableValue;
use serde::{Deserialize, Serialize};

// This type automatically implements DurableValue
#[derive(Debug, Clone, Serialize, Deserialize)]
struct OrderResult {
    order_id: String,
    status: String,
    total: f64,
}

// Use in generic functions
fn store_result<T: DurableValue>(result: T) {
    let json = serde_json::to_string(&result).unwrap();
    println!("Storing: {}", json);
}

let result = OrderResult {
    order_id: "ORD-123".to_string(),
    status: "completed".to_string(),
    total: 99.99,
};
store_result(result);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> DurableValue for T

Blanket implementation for all types meeting the bounds.