lance_core::utils::futures

Trait SharedStreamExt

Source
pub trait SharedStreamExt<'a>: Stream + Send
where Self::Item: Clone,
{ // Required method fn share( self, capacity: Capacity, ) -> (SharedStream<'a, Self::Item>, SharedStream<'a, Self::Item>); }

Required Methods§

Source

fn share( self, capacity: Capacity, ) -> (SharedStream<'a, Self::Item>, SharedStream<'a, Self::Item>)

Split a stream into two shared streams

Each shared stream will return the full set of items from the underlying stream. This works by buffering the items from the underlying stream and then replaying them to the other side.

The capacity parameter controls how many items can be buffered at once. Be careful with the capacity parameter as it can lead to deadlock if the two streams are not polled evenly.

If the capacity is unbounded then the stream could potentially buffer the entire input stream in memory.

Implementations on Foreign Types§

Source§

impl<'a, T: Clone> SharedStreamExt<'a> for BoxStream<'a, T>

Source§

fn share(self, capacity: Capacity) -> (SharedStream<'a, T>, SharedStream<'a, T>)

Implementors§