pub struct SdkOutput {Show 14 fields
pub msg_type: String,
pub subtype: Option<String>,
pub session_id: Option<String>,
pub uuid: Option<String>,
pub message: Option<Value>,
pub event: Option<Value>,
pub result: Option<String>,
pub num_turns: Option<u32>,
pub is_error: Option<bool>,
pub errors: Option<Vec<String>>,
pub usage: Option<Value>,
pub model_usage: Option<Value>,
pub request_id: Option<String>,
pub request: Option<Value>,
}Expand description
A single NDJSON message received from Claude Code’s stdout.
Uses a flat struct with optional fields rather than a tagged enum so that unknown or new message types are silently tolerated (future-proof).
Fields§
§msg_type: String§subtype: Option<String>§session_id: Option<String>§uuid: Option<String>§message: Option<Value>For assistant messages: the full message object with content array.
event: Option<Value>For stream_event messages: the stream event payload.
result: Option<String>For result messages: the final text result.
num_turns: Option<u32>For result messages: number of API turns taken.
is_error: Option<bool>For result messages: whether an error occurred.
errors: Option<Vec<String>>For result error messages: list of error strings.
usage: Option<Value>For result messages: usage counters for the completed turn.
model_usage: Option<Value>For result messages: model-specific metadata.
request_id: Option<String>For control_request messages: the request ID to echo in responses.
request: Option<Value>For control_request messages: the request payload.
Implementations§
Source§impl SdkOutput
impl SdkOutput
Sourcepub fn request_subtype(&self) -> Option<String>
pub fn request_subtype(&self) -> Option<String>
Extract the subtype from a nested request object (for control requests).
Sourcepub fn request_tool_use_id(&self) -> Option<String>
pub fn request_tool_use_id(&self) -> Option<String>
Extract the tool_use_id from a can_use_tool control request.
pub fn model_name(&self) -> Option<String>
pub fn token_usage(&self) -> Option<SdkTokenUsage>
pub fn usage_total_tokens(&self) -> u64
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SdkOutput
impl<'de> Deserialize<'de> for SdkOutput
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SdkOutput
impl RefUnwindSafe for SdkOutput
impl Send for SdkOutput
impl Sync for SdkOutput
impl Unpin for SdkOutput
impl UnsafeUnpin for SdkOutput
impl UnwindSafe for SdkOutput
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.