Skip to main content

CallbackSink

Struct CallbackSink 

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

Forwards each line to a boxed closure. Used by the FFI layer to bridge to the C stream callback.

Implementations§

Trait Implementations§

Source§

impl EventSink for CallbackSink

Source§

fn emit_line(&self, line: &str)

Emit one already-formatted line (no trailing newline expected).
Source§

fn is_tty(&self) -> bool

Whether we are attached to a TTY (affects newline escaping in tokens).
Source§

fn supports_incremental(&self) -> bool

Whether this sink consumes the incremental segment events (seg_append / seg_reset). Legacy hosts (current Android/iOS parsers) do NOT -> false, so those events are not emitted and old clients stay fully unchanged. New hosts opt in once their parser learns the incremental patch semantics.
Source§

fn started(&self, task: &str)

Source§

fn session(&self, event: &str, session_id: &str)

Source§

fn seg(&self, seg: &str, content: &str)

seg_content event. seg ∈ {thinking, thought, action, observation}
Source§

fn session_origin(&self, task: &str, session_id: &str, created: bool)

Merged startup event (additive, backward compatible): task + session identity + created flag in a single line. Legacy clients keep consuming start + session_created/session_switched; new clients can consume this one line instead and skip the two legacy lines.
Source§

fn seg_append(&self, seg: &str, content: &str)

Incremental segment update (additive, backward compatible): append content to the live segment seg without replacing its identity. New clients can patch a segment in place (no count rewind / full rebuild). Legacy clients ignore this event and keep using seg_content.
Source§

fn seg_reset(&self, seg: &str, content: &str)

Incremental segment update (additive, backward compatible): replace the live segment seg’s content in place (identity preserved). Same patching semantics as seg_append; legacy clients ignore it and keep using seg_content.
Source§

fn seg_large(&self, seg: &str, content: &str, chunk: usize)

Emit the legacy seg_content (authoritative full content, for old clients) AND, when the sink supports the incremental protocol and content is large, the incremental seg_reset + chunked seg_append pair so new clients can build the segment in place without a count rewind. Small segments only get the legacy event.
Source§

fn seg_stream(&self, seg: &str, content: &str, chunk: usize)

Chunked incremental form: reset the live segment in place, then grow it chunk by chunk. Only emitted for large content on incremental hosts; new clients patch in place (stable identity, no full-array rebuild).
Source§

fn seg_observation(&self, content: &str, max_chars: usize)

Observation segment with truncation cap. Always emits the legacy seg_content event (content capped to max_chars, matching the old preview behaviour); truncated/total_chars are additive metadata old parsers ignore and new clients use to render a collapse affordance. On incremental hosts, a truncated observation also emits the seg_reset/seg_append pair for in-place patching.
Source§

fn tool_progress(&self, state: &str, name: &str, chars: usize)

tool_progress event. state ∈ {building, done}
Source§

fn action(&self, name: &str, args: &str)

Action declaration. Pipe mode: typed JSONL event carrying the tool name so clients can render it as a structured segment. TTY mode: legacy raw line 🛠️ Action: {name}\x00Action Input: {args}.
Source§

fn delta(&self, seg: &str, text: &str)

A streaming token attributed to a channel (thinking or thought). Pipe mode emits a typed JSONL event so clients can route tokens to the right UI segment (live typewriter); TTY mode falls back to raw output.
Source§

fn token_line(&self, text: &str)

A streaming token. Newlines become \x00 in pipe mode.
Source§

fn done(&self, session_id: &str)

Source§

fn done_result( &self, session_id: &str, status: &str, iterations: u32, final_text: &str, )

Terminal event carrying the run outcome (status/iterations/final_text). Emitted once per run as the authoritative terminal marker.
Source§

fn error(&self, message: &str)

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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