pub struct UserMessage {
pub message: MessageContent,
pub session_id: Option<Uuid>,
pub parent_tool_use_id: Option<String>,
pub uuid: Option<String>,
pub timestamp: Option<String>,
pub tool_use_result: Option<Value>,
}Expand description
User message
Fields§
§message: MessageContent§session_id: Option<Uuid>§parent_tool_use_id: Option<String>Parent tool use ID for nested agent messages
uuid: Option<String>Message-level unique identifier
timestamp: Option<String>CLI-emitted ISO-8601 timestamp for the message (present on echoed tool results).
tool_use_result: Option<Value>Structured tool result data echoed by the CLI alongside the tool_result
content block. The shape depends on which tool produced it (e.g. for
AskUserQuestion it is { questions, answers }; for Bash it is
{ stdout, stderr, exit_code, ... }). Stored as raw JSON to preserve
wire fidelity; use UserMessage::tool_use_result_as to parse into a
typed shape when you know which tool was invoked.
Implementations§
Source§impl UserMessage
impl UserMessage
Sourcepub fn tool_use_result_as<T: DeserializeOwned>(
&self,
) -> Option<Result<T, Error>>
pub fn tool_use_result_as<T: DeserializeOwned>( &self, ) -> Option<Result<T, Error>>
Parse the tool_use_result field into a caller-specified type.
Returns None if tool_use_result is absent, otherwise returns the
deserialization result. The caller must know which tool produced the
result and supply a matching type — e.g. for AskUserQuestion use
AskUserQuestionInput, whose
questions + answers fields match the wire result shape.
Trait Implementations§
Source§impl Clone for UserMessage
impl Clone for UserMessage
Source§fn clone(&self) -> UserMessage
fn clone(&self) -> UserMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more