pub struct TurnResult {
pub result: Value,
pub events: Vec<Value>,
}Expand description
The result of one turn through a DuplexSession.
result is the raw JSON of the {"type": "result", ...} message
that closed the turn. events carries every other message
received during the turn (system, assistant, stream_event, user)
in arrival order, with the closing result excluded.
Fields§
§result: ValueThe raw {"type": "result", ...} message that ended the turn.
events: Vec<Value>Every other message received during the turn, in order.
Implementations§
Source§impl TurnResult
impl TurnResult
Sourcepub fn result_text(&self) -> Option<&str>
pub fn result_text(&self) -> Option<&str>
Extract result.result as a string, if present.
Sourcepub fn session_id(&self) -> Option<&str>
pub fn session_id(&self) -> Option<&str>
Extract result.session_id, if present.
Sourcepub fn total_cost_usd(&self) -> Option<f64>
pub fn total_cost_usd(&self) -> Option<f64>
Extract total_cost_usd (preferred) or the legacy cost_usd
field, if either is present.
This is the CLI’s running total for the session, not the cost
of this turn: each result message reports everything spent
so far, earlier turns included. When the session was spawned
with DuplexOptions::resume or
DuplexOptions::continue_session, the CLI restores the
resumed session’s total, so the figure also covers spend from
before this process started.
A turn’s own cost is the change from the previous turn’s
total. Conversation
records that change for each turn and keeps the cumulative
figure.
Sourcepub fn duration_ms(&self) -> Option<u64>
pub fn duration_ms(&self) -> Option<u64>
Extract duration_ms, if present.