Skip to main content

PlainTextRenderer

Struct PlainTextRenderer 

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

Plain text renderer with optional ANSI styling.

This renderer outputs text directly to stdout with optional ANSI escape codes for styling thinking blocks and tool use.

Implementations§

Source§

impl PlainTextRenderer

Source

pub fn new() -> Self

Creates a new PlainTextRenderer with ANSI colors enabled.

Source

pub fn with_color(use_color: bool) -> Self

Creates a new PlainTextRenderer with specified color setting.

Source

pub fn with_interrupt(self, interrupted: Arc<AtomicBool>) -> Self

Attaches an interrupt flag to the renderer.

Source

pub fn with_color_and_interrupt( use_color: bool, interrupted: Arc<AtomicBool>, ) -> Self

Creates a new PlainTextRenderer with specified color and interrupt flag.

Trait Implementations§

Source§

impl Default for PlainTextRenderer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Renderer for PlainTextRenderer

Source§

fn start_agent(&mut self, context: &dyn StreamContext)

Called when a stream begins.
Source§

fn finish_agent( &mut self, context: &dyn StreamContext, stop_reason: Option<&StopReason>, )

Called when a stream finishes.
Source§

fn print_text(&mut self, context: &dyn StreamContext, text: &str)

Print a chunk of regular response text. Read more
Source§

fn print_thinking(&mut self, context: &dyn StreamContext, text: &str)

Print a chunk of thinking text. Read more
Source§

fn print_error(&mut self, context: &dyn StreamContext, error: &str)

Print an error message.
Source§

fn print_info(&mut self, context: &dyn StreamContext, info: &str)

Print an informational message.
Source§

fn start_tool_use(&mut self, context: &dyn StreamContext, name: &str, id: &str)

Called when a tool use block starts. Read more
Source§

fn print_tool_input(&mut self, context: &dyn StreamContext, partial_json: &str)

Print a chunk of tool input JSON. Read more
Source§

fn finish_tool_use(&mut self, context: &dyn StreamContext)

Called when a tool use block is complete. Read more
Source§

fn start_tool_result( &mut self, context: &dyn StreamContext, tool_use_id: &str, is_error: bool, )

Called when the model streams a tool result block.
Source§

fn print_tool_result_text(&mut self, context: &dyn StreamContext, text: &str)

Print tool result text content.
Source§

fn finish_tool_result(&mut self, context: &dyn StreamContext)

Called when a tool result block is complete.
Source§

fn finish_response(&mut self, context: &dyn StreamContext)

Called when a response is complete. Read more
Source§

fn print_interrupted(&mut self, context: &dyn StreamContext)

Called when the stream is interrupted by the user.
Source§

fn should_interrupt(&self) -> bool

Returns true if streaming should be interrupted.
Source§

fn read_operator_line(&mut self, prompt: &str) -> Result<Option<OperatorLine>>

Reads a line of operator input, if this renderer is interactive. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more