pub struct StreamingProcessor { /* private fields */ }
Expand description
Streaming processor for handling real-time responses from the Gemini API
Implementations§
Source§impl StreamingProcessor
impl StreamingProcessor
Sourcepub fn with_config(config: StreamingConfig) -> Self
pub fn with_config(config: StreamingConfig) -> Self
Create a new streaming processor with custom configuration
Sourcepub async fn process_stream<F>(
&mut self,
response: Response,
on_chunk: F,
) -> Result<StreamingResponse, StreamingError>
pub async fn process_stream<F>( &mut self, response: Response, on_chunk: F, ) -> Result<StreamingResponse, StreamingError>
Process a streaming response from the Gemini API
This method takes a response and processes it in real-time, calling the provided callback for each chunk of content received.
§Arguments
response
- The HTTP response from the Gemini APIon_chunk
- A callback function that will be called for each text chunk received
§Returns
A result containing the final accumulated response or a streaming error
Sourcepub fn metrics(&self) -> &StreamingMetrics
pub fn metrics(&self) -> &StreamingMetrics
Get current streaming metrics
Sourcepub fn reset_metrics(&mut self)
pub fn reset_metrics(&mut self)
Reset streaming metrics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamingProcessor
impl RefUnwindSafe for StreamingProcessor
impl Send for StreamingProcessor
impl Sync for StreamingProcessor
impl Unpin for StreamingProcessor
impl UnwindSafe for StreamingProcessor
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