pub struct StreamParser { /* private fields */ }Expand description
Parses a model’s A2UI output incrementally, one chunk at a time.
Implementations§
Source§impl StreamParser
impl StreamParser
Sourcepub fn with_cuttable_keys<I, S>(self, keys: I) -> Self
pub fn with_cuttable_keys<I, S>(self, keys: I) -> Self
Overrides which keys may have their string values closed early.
A catalog whose components carry long free-text properties under other names can add them here to keep those streaming smoothly.
Sourcepub fn without_validation(self) -> Self
pub fn without_validation(self) -> Self
Turns off validation, emitting whatever parses.
Only useful when the catalog is not known to this process; the filtering that validation provides is most of what makes partial output safe to render.
Sourcepub fn surface_id(&self) -> Option<&str>
pub fn surface_id(&self) -> Option<&str>
The surface the stream is currently describing.
Sourcepub fn process_chunk(&mut self, chunk: &str) -> Result<Vec<ResponsePart>>
pub fn process_chunk(&mut self, chunk: &str) -> Result<Vec<ResponsePart>>
Feeds the next chunk of the model’s output.
Returns the parts that became renderable because of this chunk: conversational text, complete A2UI messages, and partial updates that are safe to draw. An empty vector means the chunk did not complete anything.
§Errors
Returns Error::Parse for a block that contained no JSON at all, and
Error::Validation for output no further input can rescue: a message
matching no envelope, a missing required envelope field, or a reference
loop.
Trait Implementations§
Source§impl Clone for StreamParser
impl Clone for StreamParser
Source§fn clone(&self) -> StreamParser
fn clone(&self) -> StreamParser
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more