pub trait DurableContextOps {
Show 26 methods
// Required methods
fn step<T, E, F, Fut>(
&mut self,
name: &str,
f: F,
) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Send
where T: Serialize + DeserializeOwned + Send + 'static,
E: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce() -> Fut + Send + 'static,
Fut: Future<Output = Result<T, E>> + Send + 'static;
fn step_with_options<T, E, F, Fut>(
&mut self,
name: &str,
options: StepOptions,
f: F,
) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Send
where T: Serialize + DeserializeOwned + Send + 'static,
E: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce() -> Fut + Send + 'static,
Fut: Future<Output = Result<T, E>> + Send + 'static;
fn wait(
&mut self,
name: &str,
duration_secs: i32,
) -> impl Future<Output = Result<(), DurableError>> + Send;
fn create_callback(
&mut self,
name: &str,
options: CallbackOptions,
) -> impl Future<Output = Result<CallbackHandle, DurableError>> + Send;
fn invoke<T, P>(
&mut self,
name: &str,
function_name: &str,
payload: &P,
) -> impl Future<Output = Result<T, DurableError>> + Send
where T: DeserializeOwned + Send,
P: Serialize + Sync;
fn parallel<T, F, Fut>(
&mut self,
name: &str,
branches: Vec<F>,
options: ParallelOptions,
) -> impl Future<Output = Result<BatchResult<T>, DurableError>> + Send
where T: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce(DurableContext) -> Fut + Send + 'static,
Fut: Future<Output = Result<T, DurableError>> + Send + 'static;
fn child_context<T, F, Fut>(
&mut self,
name: &str,
f: F,
) -> impl Future<Output = Result<T, DurableError>> + Send
where T: Serialize + DeserializeOwned + Send,
F: FnOnce(DurableContext) -> Fut + Send,
Fut: Future<Output = Result<T, DurableError>> + Send;
fn map<T, I, F, Fut>(
&mut self,
name: &str,
items: Vec<I>,
options: MapOptions,
f: F,
) -> impl Future<Output = Result<BatchResult<T>, DurableError>> + Send
where T: Serialize + DeserializeOwned + Send + 'static,
I: Send + 'static,
F: FnOnce(I, DurableContext) -> Fut + Send + 'static + Clone,
Fut: Future<Output = Result<T, DurableError>> + Send + 'static;
fn step_with_compensation<T, E, F, Fut, G, GFut>(
&mut self,
name: &str,
forward_fn: F,
compensate_fn: G,
) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Send
where T: Serialize + DeserializeOwned + Send + 'static,
E: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce() -> Fut + Send + 'static,
Fut: Future<Output = Result<T, E>> + Send + 'static,
G: FnOnce(T) -> GFut + Send + 'static,
GFut: Future<Output = Result<(), DurableError>> + Send + 'static;
fn step_with_compensation_opts<T, E, F, Fut, G, GFut>(
&mut self,
name: &str,
options: StepOptions,
forward_fn: F,
compensate_fn: G,
) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Send
where T: Serialize + DeserializeOwned + Send + 'static,
E: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce() -> Fut + Send + 'static,
Fut: Future<Output = Result<T, E>> + Send + 'static,
G: FnOnce(T) -> GFut + Send + 'static,
GFut: Future<Output = Result<(), DurableError>> + Send + 'static;
fn run_compensations(
&mut self,
) -> impl Future<Output = Result<CompensationResult, DurableError>> + Send;
fn callback_result<T: DeserializeOwned>(
&self,
handle: &CallbackHandle,
) -> Result<T, DurableError>;
fn execution_mode(&self) -> ExecutionMode;
fn is_replaying(&self) -> bool;
fn arn(&self) -> &str;
fn checkpoint_token(&self) -> &str;
fn log(&self, message: &str);
fn log_with_data(&self, message: &str, data: &Value);
fn log_debug(&self, message: &str);
fn log_warn(&self, message: &str);
fn log_error(&self, message: &str);
fn log_debug_with_data(&self, message: &str, data: &Value);
fn log_warn_with_data(&self, message: &str, data: &Value);
fn log_error_with_data(&self, message: &str, data: &Value);
fn enable_batch_mode(&mut self);
fn flush_batch(
&mut self,
) -> impl Future<Output = Result<(), DurableError>> + Send;
}Expand description
Shared interface for all durable context types.
Every context type in the SDK implements this trait by delegating to the
underlying DurableContext or its inherent methods. Use this trait as a
generic bound when writing handler logic that should work across all context
approaches (closure, trait, builder, or core directly).
§Static dispatch only
This trait uses native async (-> impl Future<...>) and is designed for
static dispatch. Do not use dyn DurableContextOps — there is no
object-safe version.
§Examples
use durable_lambda_core::DurableContextOps;
use durable_lambda_core::error::DurableError;
async fn process_order<C: DurableContextOps>(ctx: &mut C, order_id: u64) -> Result<(), DurableError> {
let _result: Result<String, String> = ctx.step("validate", move || async move {
Ok(format!("validated:{order_id}"))
}).await?;
ctx.log("order processed");
Ok(())
}Required Methods§
Sourcefn step<T, E, F, Fut>(
&mut self,
name: &str,
f: F,
) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Send
fn step<T, E, F, Fut>( &mut self, name: &str, f: F, ) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Send
Execute a named step with checkpointing.
See DurableContext::step for full
documentation.
Sourcefn step_with_options<T, E, F, Fut>(
&mut self,
name: &str,
options: StepOptions,
f: F,
) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Send
fn step_with_options<T, E, F, Fut>( &mut self, name: &str, options: StepOptions, f: F, ) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Send
Execute a named step with checkpointing and retry configuration.
See DurableContext::step_with_options for full
documentation.
Sourcefn wait(
&mut self,
name: &str,
duration_secs: i32,
) -> impl Future<Output = Result<(), DurableError>> + Send
fn wait( &mut self, name: &str, duration_secs: i32, ) -> impl Future<Output = Result<(), DurableError>> + Send
Suspend execution for the specified duration.
See DurableContext::wait for full
documentation.
Sourcefn create_callback(
&mut self,
name: &str,
options: CallbackOptions,
) -> impl Future<Output = Result<CallbackHandle, DurableError>> + Send
fn create_callback( &mut self, name: &str, options: CallbackOptions, ) -> impl Future<Output = Result<CallbackHandle, DurableError>> + Send
Register a callback and return a handle with the server-generated callback ID.
See DurableContext::create_callback for full
documentation.
Sourcefn invoke<T, P>(
&mut self,
name: &str,
function_name: &str,
payload: &P,
) -> impl Future<Output = Result<T, DurableError>> + Send
fn invoke<T, P>( &mut self, name: &str, function_name: &str, payload: &P, ) -> impl Future<Output = Result<T, DurableError>> + Send
Durably invoke another Lambda function and return its result.
See DurableContext::invoke for full
documentation.
Sourcefn parallel<T, F, Fut>(
&mut self,
name: &str,
branches: Vec<F>,
options: ParallelOptions,
) -> impl Future<Output = Result<BatchResult<T>, DurableError>> + Sendwhere
T: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce(DurableContext) -> Fut + Send + 'static,
Fut: Future<Output = Result<T, DurableError>> + Send + 'static,
fn parallel<T, F, Fut>(
&mut self,
name: &str,
branches: Vec<F>,
options: ParallelOptions,
) -> impl Future<Output = Result<BatchResult<T>, DurableError>> + Sendwhere
T: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce(DurableContext) -> Fut + Send + 'static,
Fut: Future<Output = Result<T, DurableError>> + Send + 'static,
Execute multiple branches concurrently and return their results.
See DurableContext::parallel for full
documentation.
Sourcefn child_context<T, F, Fut>(
&mut self,
name: &str,
f: F,
) -> impl Future<Output = Result<T, DurableError>> + Sendwhere
T: Serialize + DeserializeOwned + Send,
F: FnOnce(DurableContext) -> Fut + Send,
Fut: Future<Output = Result<T, DurableError>> + Send,
fn child_context<T, F, Fut>(
&mut self,
name: &str,
f: F,
) -> impl Future<Output = Result<T, DurableError>> + Sendwhere
T: Serialize + DeserializeOwned + Send,
F: FnOnce(DurableContext) -> Fut + Send,
Fut: Future<Output = Result<T, DurableError>> + Send,
Execute an isolated subflow with its own checkpoint namespace.
See DurableContext::child_context for full
documentation.
Sourcefn map<T, I, F, Fut>(
&mut self,
name: &str,
items: Vec<I>,
options: MapOptions,
f: F,
) -> impl Future<Output = Result<BatchResult<T>, DurableError>> + Sendwhere
T: Serialize + DeserializeOwned + Send + 'static,
I: Send + 'static,
F: FnOnce(I, DurableContext) -> Fut + Send + 'static + Clone,
Fut: Future<Output = Result<T, DurableError>> + Send + 'static,
fn map<T, I, F, Fut>(
&mut self,
name: &str,
items: Vec<I>,
options: MapOptions,
f: F,
) -> impl Future<Output = Result<BatchResult<T>, DurableError>> + Sendwhere
T: Serialize + DeserializeOwned + Send + 'static,
I: Send + 'static,
F: FnOnce(I, DurableContext) -> Fut + Send + 'static + Clone,
Fut: Future<Output = Result<T, DurableError>> + Send + 'static,
Process a collection of items in parallel and return their results.
See DurableContext::map for full
documentation.
Sourcefn step_with_compensation<T, E, F, Fut, G, GFut>(
&mut self,
name: &str,
forward_fn: F,
compensate_fn: G,
) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Sendwhere
T: Serialize + DeserializeOwned + Send + 'static,
E: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce() -> Fut + Send + 'static,
Fut: Future<Output = Result<T, E>> + Send + 'static,
G: FnOnce(T) -> GFut + Send + 'static,
GFut: Future<Output = Result<(), DurableError>> + Send + 'static,
fn step_with_compensation<T, E, F, Fut, G, GFut>(
&mut self,
name: &str,
forward_fn: F,
compensate_fn: G,
) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Sendwhere
T: Serialize + DeserializeOwned + Send + 'static,
E: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce() -> Fut + Send + 'static,
Fut: Future<Output = Result<T, E>> + Send + 'static,
G: FnOnce(T) -> GFut + Send + 'static,
GFut: Future<Output = Result<(), DurableError>> + Send + 'static,
Execute a forward step and register a compensation closure on success.
See DurableContext::step_with_compensation for full
documentation.
Sourcefn step_with_compensation_opts<T, E, F, Fut, G, GFut>(
&mut self,
name: &str,
options: StepOptions,
forward_fn: F,
compensate_fn: G,
) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Sendwhere
T: Serialize + DeserializeOwned + Send + 'static,
E: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce() -> Fut + Send + 'static,
Fut: Future<Output = Result<T, E>> + Send + 'static,
G: FnOnce(T) -> GFut + Send + 'static,
GFut: Future<Output = Result<(), DurableError>> + Send + 'static,
fn step_with_compensation_opts<T, E, F, Fut, G, GFut>(
&mut self,
name: &str,
options: StepOptions,
forward_fn: F,
compensate_fn: G,
) -> impl Future<Output = Result<Result<T, E>, DurableError>> + Sendwhere
T: Serialize + DeserializeOwned + Send + 'static,
E: Serialize + DeserializeOwned + Send + 'static,
F: FnOnce() -> Fut + Send + 'static,
Fut: Future<Output = Result<T, E>> + Send + 'static,
G: FnOnce(T) -> GFut + Send + 'static,
GFut: Future<Output = Result<(), DurableError>> + Send + 'static,
Execute a forward step (with options) and register a compensation closure on success.
See DurableContext::step_with_compensation_opts for full
documentation.
Sourcefn run_compensations(
&mut self,
) -> impl Future<Output = Result<CompensationResult, DurableError>> + Send
fn run_compensations( &mut self, ) -> impl Future<Output = Result<CompensationResult, DurableError>> + Send
Execute all registered compensations in reverse registration order.
See DurableContext::run_compensations for full
documentation.
Sourcefn callback_result<T: DeserializeOwned>(
&self,
handle: &CallbackHandle,
) -> Result<T, DurableError>
fn callback_result<T: DeserializeOwned>( &self, handle: &CallbackHandle, ) -> Result<T, DurableError>
Check the result of a previously created callback.
See DurableContext::callback_result for full
documentation.
Sourcefn execution_mode(&self) -> ExecutionMode
fn execution_mode(&self) -> ExecutionMode
Return the current execution mode (Replaying or Executing).
Sourcefn is_replaying(&self) -> bool
fn is_replaying(&self) -> bool
Return whether the context is currently replaying from history.
Sourcefn checkpoint_token(&self) -> &str
fn checkpoint_token(&self) -> &str
Return the current checkpoint token.
Sourcefn log_with_data(&self, message: &str, data: &Value)
fn log_with_data(&self, message: &str, data: &Value)
Emit a replay-safe info-level log message with structured data.
Sourcefn log_debug_with_data(&self, message: &str, data: &Value)
fn log_debug_with_data(&self, message: &str, data: &Value)
Emit a replay-safe debug-level log message with structured data.
Sourcefn log_warn_with_data(&self, message: &str, data: &Value)
fn log_warn_with_data(&self, message: &str, data: &Value)
Emit a replay-safe warn-level log message with structured data.
Sourcefn log_error_with_data(&self, message: &str, data: &Value)
fn log_error_with_data(&self, message: &str, data: &Value)
Emit a replay-safe error-level log message with structured data.
Sourcefn enable_batch_mode(&mut self)
fn enable_batch_mode(&mut self)
Enable batch checkpoint mode.
See DurableContext::enable_batch_mode for full
documentation.
Sourcefn flush_batch(
&mut self,
) -> impl Future<Output = Result<(), DurableError>> + Send
fn flush_batch( &mut self, ) -> impl Future<Output = Result<(), DurableError>> + Send
Flush accumulated batch checkpoint updates.
See DurableContext::flush_batch for full
documentation.
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.