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.
Sourcepub fn duration_ms(&self) -> Option<u64>
pub fn duration_ms(&self) -> Option<u64>
Extract duration_ms, if present.
Trait Implementations§
Source§impl Clone for TurnResult
impl Clone for TurnResult
Source§fn clone(&self) -> TurnResult
fn clone(&self) -> TurnResult
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TurnResult
impl RefUnwindSafe for TurnResult
impl Send for TurnResult
impl Sync for TurnResult
impl Unpin for TurnResult
impl UnsafeUnpin for TurnResult
impl UnwindSafe for TurnResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more