Skip to main content

StepOutput

Derive Macro StepOutput 

Source
#[derive(StepOutput)]
Expand description

Derive macro for type-safe step output extraction

Generates:

  • from_context(ctx, step_name) method for extracting typed output
  • Into<StepExecutionResult> impl for returning typed output

§Example

#[derive(StepOutput)]
struct ValidateAndCreateTradeOutput {
    trade_id: Uuid,
    idempotency_key: String,
}

// In step execute method:
let output: ValidateAndCreateTradeOutput = ValidateAndCreateTradeOutput {
    trade_id: trade.id,
    idempotency_key: trade.idempotency_key,
};
return output.into(); // Converts to StepExecutionResult

// In another step:
let output = ValidateAndCreateTradeOutput::from_context(ctx, "ValidateAndCreateTrade")?;
let trade_id = output.trade_id;