Skip to main content

StepOutput

Struct StepOutput 

Source
pub struct StepOutput {
    pub output: Value,
    pub duration_ms: u64,
    pub cost_usd: Decimal,
    pub input_tokens: Option<u64>,
    pub output_tokens: Option<u64>,
    pub model: Option<String>,
    pub debug_messages: Option<Vec<DebugMessage>>,
}
Expand description

Result of executing a single step.

Fields§

§output: Value

Serialized output (stdout for shell, body for http, value for agent).

For agent steps with a JSON schema, the value may not strictly conform to the schema: Claude CLI can flatten wrapper objects with a single array field, returning a bare array instead of {"items": [...]}. Callers should handle both the expected wrapper and a bare value.

§duration_ms: u64

Wall-clock duration in milliseconds.

§cost_usd: Decimal

Cost in USD (agent steps only).

§input_tokens: Option<u64>

Input token count (agent steps only).

§output_tokens: Option<u64>

Output token count (agent steps only).

§model: Option<String>

Model identifier used for agent steps (e.g. "claude-sonnet-4-20250514").

§debug_messages: Option<Vec<DebugMessage>>

Conversation trace from verbose agent invocations.

Implementations§

Source§

impl StepOutput

Source

pub fn debug_messages_json(&self) -> Option<Value>

Serialize debug messages to a JSON Value for store persistence.

Returns None when verbose mode was off (no messages captured).

Source

pub fn exit_code(&self) -> Option<i64>

Exit code of a shell step.

Returns None for non-shell steps or when the field is absent.

§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;

let output = StepOutput {
    output: json!({"stdout": "ok\n", "stderr": "", "exit_code": 0}),
    duration_ms: 3,
    cost_usd: Decimal::ZERO,
    input_tokens: None,
    output_tokens: None,
    model: None,
    debug_messages: None,
};
assert_eq!(output.exit_code(), Some(0));
Source

pub fn stdout(&self) -> &str

Standard output of a shell step, or an empty string for other kinds.

§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;

let output = StepOutput {
    output: json!({"stdout": "42 tests passed\n", "stderr": "", "exit_code": 0}),
    duration_ms: 3,
    cost_usd: Decimal::ZERO,
    input_tokens: None,
    output_tokens: None,
    model: None,
    debug_messages: None,
};
assert!(output.stdout().contains("42 tests"));
Source

pub fn stderr(&self) -> &str

Standard error of a shell step, or an empty string for other kinds.

§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;

let output = StepOutput {
    output: json!({"stdout": "", "stderr": "warning: unused", "exit_code": 0}),
    duration_ms: 3,
    cost_usd: Decimal::ZERO,
    input_tokens: None,
    output_tokens: None,
    model: None,
    debug_messages: None,
};
assert_eq!(output.stderr(), "warning: unused");
Source

pub fn status(&self) -> Option<u16>

HTTP status code of an HTTP step.

Returns None for non-HTTP steps or when the field is absent.

§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;

let output = StepOutput {
    output: json!({"status": 204, "body": ""}),
    duration_ms: 3,
    cost_usd: Decimal::ZERO,
    input_tokens: None,
    output_tokens: None,
    model: None,
    debug_messages: None,
};
assert_eq!(output.status(), Some(204));
Source

pub fn body(&self) -> &str

Response body of an HTTP step, or an empty string for other kinds.

§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;

let output = StepOutput {
    output: json!({"status": 200, "body": "{\"ok\":true}"}),
    duration_ms: 3,
    cost_usd: Decimal::ZERO,
    input_tokens: None,
    output_tokens: None,
    model: None,
    debug_messages: None,
};
assert_eq!(output.body(), "{\"ok\":true}");
Source

pub fn is_success(&self) -> bool

Whether the step succeeded from the point of view of its own kind.

  • Shell step: the exit code is 0.
  • HTTP step: the status is in the 2xx range.
  • Any other kind: false, since no success marker is recorded.

Mostly useful after a step configured with allow_failure(), since a failing step otherwise returns an error from the context method.

§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;

let shell = StepOutput {
    output: json!({"stdout": "", "stderr": "", "exit_code": 1}),
    duration_ms: 3,
    cost_usd: Decimal::ZERO,
    input_tokens: None,
    output_tokens: None,
    model: None,
    debug_messages: None,
};
assert!(!shell.is_success());

let http = StepOutput { output: json!({"status": 201, "body": ""}), ..shell.clone() };
assert!(http.is_success());
Source

pub fn json<T: DeserializeOwned>(&self) -> Result<T, EngineError>

Deserialize the step output into T.

Intended for agent steps constrained by a JSON schema, and for custom operations that return structured JSON.

§Errors

Returns EngineError::Serialization when the output does not match T.

§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde::Deserialize;
use serde_json::json;

#[derive(Deserialize)]
struct Review {
    score: u8,
}

let output = StepOutput {
    output: json!({"score": 8}),
    duration_ms: 3,
    cost_usd: Decimal::ZERO,
    input_tokens: None,
    output_tokens: None,
    model: None,
    debug_messages: None,
};
let review: Review = output.json()?;
assert_eq!(review.score, 8);

Trait Implementations§

Source§

impl Clone for StepOutput

Source§

fn clone(&self) -> StepOutput

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StepOutput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more