Skip to main content

StreamExt

Trait StreamExt 

Source
pub trait StreamExt: Stream {
    // Provided methods
    fn collect_text(self) -> CollectText<Self> 
       where Self: Sized { ... }
    fn filter_empty(self) -> FilterEmpty<Self>
       where Self: Sized { ... }
    fn buffer_chunks(self, duration: Duration) -> BufferChunks<Self>
       where Self: Sized { ... }
}
Expand description

Extension trait for streams with convenience methods.

Provided Methods§

Source

fn collect_text(self) -> CollectText<Self>
where Self: Sized,

Collect all chunks into a single string.

This method consumes the stream and collects all the delta content from each chunk into a single string.

§Returns

A future that resolves to the complete text or an error

Source

fn filter_empty(self) -> FilterEmpty<Self>
where Self: Sized,

Filter out chunks with empty delta content.

§Returns

A stream that only yields chunks with non-empty delta content

Source

fn buffer_chunks(self, duration: Duration) -> BufferChunks<Self>
where Self: Sized,

Buffer chunks for a given duration before yielding them.

This can be useful to reduce the frequency of updates in UI applications.

§Arguments
  • duration - The buffer duration
§Returns

A stream that yields buffered chunks

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> StreamExt for T
where T: Stream + ?Sized,