struct StreamPrinter {
enabled: bool,
color: Style,
started: bool,
last_was_newline: bool,
}Expand description
Streams a subprocess backend’s assistant text and reasoning to stdout as the CLI emits it, mirroring the openai backend. This is chunk-level: each CLI event (text block / part / item) is printed whole as it arrives, not token-by-token. Reasoning is dimmed to set it apart from the answer. Tool-call lines are printed separately to stderr and are not handled here.
Fields§
§enabled: bool§color: Style§started: bool§last_was_newline: boolImplementations§
Source§impl StreamPrinter
impl StreamPrinter
fn new(enabled: bool, color: Style) -> Self
fn emit(&mut self, to_print: &str, raw: &str) -> Result<()>
Sourcefn reasoning(&mut self, s: &str) -> Result<()>
fn reasoning(&mut self, s: &str) -> Result<()>
Reasoning / thinking, dimmed to distinguish it from the answer. Trailing newline is tracked from the raw text, not the styled (ANSI-wrapped) string.
Sourcefn newline(&mut self)
fn newline(&mut self)
End the current line if the last chunk did not already. Use after a
whole-block event (claude/codex) so consecutive blocks don’t run together;
also called once at the end via [finish].
fn finish(&mut self)
Auto Trait Implementations§
impl Freeze for StreamPrinter
impl RefUnwindSafe for StreamPrinter
impl Send for StreamPrinter
impl Sync for StreamPrinter
impl Unpin for StreamPrinter
impl UnsafeUnpin for StreamPrinter
impl UnwindSafe for StreamPrinter
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