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
impl EventSink for CallbackSink
Source§fn emit_line(&self, line: &str)
fn emit_line(&self, line: &str)
Emit one already-formatted line (no trailing newline expected).
Source§fn is_tty(&self) -> bool
fn is_tty(&self) -> bool
Whether we are attached to a TTY (affects newline escaping in tokens).
Source§fn supports_incremental(&self) -> bool
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.fn started(&self, task: &str)
fn session(&self, event: &str, session_id: &str)
Source§fn seg(&self, seg: &str, content: &str)
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)
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)
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)
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)
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)
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)
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)
fn tool_progress(&self, state: &str, name: &str, chars: usize)
tool_progress event. state ∈ {building, done}
Source§fn action(&self, name: &str, args: &str)
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)
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)
fn token_line(&self, text: &str)
A streaming token. Newlines become \x00 in pipe mode.
fn done(&self, session_id: &str)
Source§fn done_result(
&self,
session_id: &str,
status: &str,
iterations: u32,
final_text: &str,
)
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.
fn error(&self, message: &str)
Auto Trait Implementations§
impl !RefUnwindSafe for CallbackSink
impl !UnwindSafe for CallbackSink
impl Freeze for CallbackSink
impl Send for CallbackSink
impl Sync for CallbackSink
impl Unpin for CallbackSink
impl UnsafeUnpin for CallbackSink
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