Skip to main content

ClaudeParser

Struct ClaudeParser 

Source
pub struct ClaudeParser { /* private fields */ }
Expand description

Claude event parser

Note: This parser is designed for single-threaded use only. The internal state uses Rc<RefCell<>> for convenience, not for thread safety. Do not share this parser across threads.

Implementations§

Source§

impl ClaudeParser

Source

pub fn new(colors: Colors, verbosity: Verbosity) -> Self

Create a new ClaudeParser with the given colors and verbosity.

§Arguments
  • colors - Colors for terminal output
  • verbosity - Verbosity level for output
§Returns

A new ClaudeParser instance

§Example
use ralph_workflow::json_parser::ClaudeParser;
use ralph_workflow::logger::Colors;
use ralph_workflow::config::Verbosity;

let parser = ClaudeParser::new(Colors::new(), Verbosity::Normal);
Source

pub fn with_printer( colors: Colors, verbosity: Verbosity, printer: SharedPrinter, ) -> Self

Create a new ClaudeParser with a custom printer.

§Arguments
  • colors - Colors for terminal output
  • verbosity - Verbosity level for output
  • printer - Shared printer for output
§Returns

A new ClaudeParser instance

Source

pub fn with_display_name(self, display_name: &str) -> Self

Set the display name for this parser.

§Arguments
  • display_name - The name to display in output
§Returns

Self for builder pattern chaining

Source

pub fn parse_event(&self, line: &str) -> Option<String>

Parse and display a single Claude JSON event

Returns Some(formatted_output) for valid events, or None for:

  • Malformed JSON (logged at debug level)
  • Unknown event types
  • Empty or whitespace-only output
Source

pub fn parse_stream<R: BufRead>( &self, reader: R, workspace: &dyn Workspace, ) -> Result<()>

Parse a stream of Claude NDJSON events

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.