pub struct StreamingTextState {
pub content: String,
pub streaming: bool,
/* private fields */
}Expand description
State for a streaming text display.
Accumulates text chunks as they arrive from an LLM stream.
Pass to Context::streaming_text each frame.
Fields§
§content: StringThe accumulated text content.
streaming: boolWhether the stream is still receiving data.
Implementations§
Source§impl StreamingTextState
impl StreamingTextState
Sourcepub fn version(&self) -> u64
pub fn version(&self) -> u64
Monotonic version counter, bumped on every content mutation
(push / start / clear).
The stream itself changes every token, so this value is not a
useful cache key for the streaming region. Its purpose is the
inverse: it lets you detect when the stream did change so you can
decide whether the surrounding static chrome is stable. Combine a
hash of your non-streaming inputs into a key for
ContainerBuilder::cached and wrap
the chrome — not the stream — in it.
Since 0.21.0.
§Example
let mut stream = slt::StreamingTextState::new();
stream.push("hello");
assert_eq!(stream.version(), 1);
stream.push(" world");
assert_eq!(stream.version(), 2);Trait Implementations§
Source§impl Clone for StreamingTextState
impl Clone for StreamingTextState
Source§fn clone(&self) -> StreamingTextState
fn clone(&self) -> StreamingTextState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StreamingTextState
impl Debug for StreamingTextState
Auto Trait Implementations§
impl Freeze for StreamingTextState
impl RefUnwindSafe for StreamingTextState
impl Send for StreamingTextState
impl Sync for StreamingTextState
impl Unpin for StreamingTextState
impl UnsafeUnpin for StreamingTextState
impl UnwindSafe for StreamingTextState
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