Skip to main content

extract_user_event

Function extract_user_event 

Source
pub fn extract_user_event(initial_state: &Value) -> Value
Expand description

Extract the user’s original event payload from the InitialExecutionState.

The first operation with type EXECUTION contains the user’s input payload in its ExecutionDetails.InputPayload field. If not found or unparsable, returns an empty JSON object.

§Examples

let state = serde_json::json!({
    "Operations": [{
        "Id": "exec-1",
        "Type": "Execution",
        "Status": "Started",
        "ExecutionDetails": {
            "InputPayload": "{\"order_id\": 42}"
        }
    }]
});
let event = durable_lambda_core::event::extract_user_event(&state);
assert_eq!(event["order_id"], 42);