pub enum ClaudeOutput {
System(SystemMessage),
User(UserMessage),
Assistant(AssistantMessage),
Result(ResultMessage),
}Expand description
Top-level enum for all possible Claude output messages
Variants§
System(SystemMessage)
System initialization message
User(UserMessage)
User message echoed back
Assistant(AssistantMessage)
Assistant response
Result(ResultMessage)
Result message (completion of a query)
Implementations§
Source§impl ClaudeOutput
impl ClaudeOutput
Sourcepub fn message_type(&self) -> String
pub fn message_type(&self) -> String
Get the message type as a string
Sourcepub fn is_assistant_message(&self) -> bool
pub fn is_assistant_message(&self) -> bool
Check if this is an assistant message
Sourcepub fn is_system_message(&self) -> bool
pub fn is_system_message(&self) -> bool
Check if this is a system message
Sourcepub fn parse_json_tolerant(s: &str) -> Result<ClaudeOutput, ParseError>
pub fn parse_json_tolerant(s: &str) -> Result<ClaudeOutput, ParseError>
Parse a JSON string, handling potential ANSI escape codes and other prefixes This method will:
- First try to parse as-is
- If that fails, trim until it finds a ‘{’ and try again
Sourcepub fn parse_json(s: &str) -> Result<ClaudeOutput, ParseError>
pub fn parse_json(s: &str) -> Result<ClaudeOutput, ParseError>
Parse a JSON string, returning ParseError with raw JSON if it doesn’t match our types
Trait Implementations§
Source§impl Clone for ClaudeOutput
impl Clone for ClaudeOutput
Source§fn clone(&self) -> ClaudeOutput
fn clone(&self) -> ClaudeOutput
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClaudeOutput
impl Debug for ClaudeOutput
Source§impl<'de> Deserialize<'de> for ClaudeOutput
impl<'de> Deserialize<'de> for ClaudeOutput
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ClaudeOutput
impl RefUnwindSafe for ClaudeOutput
impl Send for ClaudeOutput
impl Sync for ClaudeOutput
impl Unpin for ClaudeOutput
impl UnwindSafe for ClaudeOutput
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