pub struct ChunkNormalizer { /* private fields */ }Expand description
Expands chunk events into the explicit events the rest of the protocol is written in.
Feed every event of a run through it, in order, and apply what comes out. Events that are not chunks pass through untouched — but they are still observed, so that an explicitly opened message can absorb a following bare chunk, and so an explicit end is not duplicated.
Implementations§
Source§impl ChunkNormalizer
impl ChunkNormalizer
Sourcepub fn normalize(&mut self, event: Event, out: &mut Vec<Event>) -> Result<()>
pub fn normalize(&mut self, event: Event, out: &mut Vec<Event>) -> Result<()>
Expands one event, appending the result to out.
Appends between zero and three events: the synthesized end of the previous stream, the synthesized start of this one, and the content.
§Errors
A chunk that names no stream and has none to continue — none open, or several subagents’ open and no attribution to pick one — or a tool call chunk that opens a call without naming the tool, is a protocol violation: there is no id to attach the payload to, and guessing one would put text in the wrong message.
Trait Implementations§
Source§impl Clone for ChunkNormalizer
impl Clone for ChunkNormalizer
Source§fn clone(&self) -> ChunkNormalizer
fn clone(&self) -> ChunkNormalizer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more