pub struct BraintrustStream { /* private fields */ }Expand description
A stream aggregator that collects streaming chunks and produces a final value.
This follows the JS/Python SDK pattern where streaming responses are
collected and aggregated lazily when final_value() is called.
Raw chunks are stored as-is during streaming (non-blocking), and transformation to universal format happens during aggregation (which runs async in a spawned task).
Implementations§
Source§impl BraintrustStream
impl BraintrustStream
Sourcepub fn push(&mut self, value: Value)
pub fn push(&mut self, value: Value)
Add a raw JSON value to the stream.
Stores the raw chunk as-is for later aggregation. This is non-blocking
to avoid adding latency to the streaming hot path. Transformation to
universal format happens lazily in aggregate().
Sourcepub fn final_value(&mut self) -> Result<&FinalizedStream>
pub fn final_value(&mut self) -> Result<&FinalizedStream>
Get the final aggregated value.
This aggregates all chunks into a final response. The result is cached, so subsequent calls return the same value.
Trait Implementations§
Source§impl Clone for BraintrustStream
impl Clone for BraintrustStream
Source§fn clone(&self) -> BraintrustStream
fn clone(&self) -> BraintrustStream
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for BraintrustStream
impl Default for BraintrustStream
Source§fn default() -> BraintrustStream
fn default() -> BraintrustStream
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BraintrustStream
impl RefUnwindSafe for BraintrustStream
impl Send for BraintrustStream
impl Sync for BraintrustStream
impl Unpin for BraintrustStream
impl UnwindSafe for BraintrustStream
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