pub struct StreamAccumulator { /* private fields */ }Expand description
Helper to accumulate streamed content into a final response.
This struct collects StreamDelta events and can convert them
into the final content blocks once the stream is complete.
Implementations§
Source§impl StreamAccumulator
impl StreamAccumulator
Sourcepub fn apply(&mut self, delta: &StreamDelta)
pub fn apply(&mut self, delta: &StreamDelta)
Apply a stream delta to the accumulator.
Sourcepub const fn stop_reason(&self) -> Option<&StopReason>
pub const fn stop_reason(&self) -> Option<&StopReason>
Get the stop reason.
Sourcepub fn into_content_blocks(self) -> Vec<ContentBlock>
pub fn into_content_blocks(self) -> Vec<ContentBlock>
Convert accumulated content to ContentBlocks.
This consumes the accumulator and returns the final content blocks. Tool use JSON is parsed at this point; invalid JSON results in a null input.
Sourcepub const fn take_usage(&mut self) -> Option<Usage>
pub const fn take_usage(&mut self) -> Option<Usage>
Take ownership of accumulated usage.
Sourcepub const fn take_stop_reason(&mut self) -> Option<StopReason>
pub const fn take_stop_reason(&mut self) -> Option<StopReason>
Take ownership of stop reason.
Trait Implementations§
Source§impl Debug for StreamAccumulator
impl Debug for StreamAccumulator
Source§impl Default for StreamAccumulator
impl Default for StreamAccumulator
Source§fn default() -> StreamAccumulator
fn default() -> StreamAccumulator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StreamAccumulator
impl RefUnwindSafe for StreamAccumulator
impl Send for StreamAccumulator
impl Sync for StreamAccumulator
impl Unpin for StreamAccumulator
impl UnwindSafe for StreamAccumulator
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