pub struct StreamBuffer { /* private fields */ }Expand description
Buffer that accumulates streaming tokens and decides when to flush.
Implementations§
Source§impl StreamBuffer
impl StreamBuffer
Sourcepub fn new(config: StreamConfig) -> Self
pub fn new(config: StreamConfig) -> Self
Create a new stream buffer.
Sourcepub fn should_flush(&self) -> bool
pub fn should_flush(&self) -> bool
Check if a flush is needed based on strategy and timing.
Sourcepub fn flush(&mut self) -> Option<FlushAction>
pub fn flush(&mut self) -> Option<FlushAction>
Get the current content to send/edit.
For EditInPlace: returns full accumulated content with cursor. For Chunked: returns the pending chunk and clears the buffer.
Sourcepub fn content_len(&self) -> usize
pub fn content_len(&self) -> usize
Get current content length.
Sourcepub fn needs_split(&self) -> bool
pub fn needs_split(&self) -> bool
Check if content exceeds max message length and needs splitting.
Sourcepub fn split_content(&self) -> Vec<String>
pub fn split_content(&self) -> Vec<String>
Split content into message-sized chunks.
Auto Trait Implementations§
impl Freeze for StreamBuffer
impl RefUnwindSafe for StreamBuffer
impl Send for StreamBuffer
impl Sync for StreamBuffer
impl Unpin for StreamBuffer
impl UnsafeUnpin for StreamBuffer
impl UnwindSafe for StreamBuffer
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