Trait mz_ore::future::OreStreamExt

source ·
pub trait OreStreamExt: Stream {
    // Required method
    fn recv_many<'life0, 'async_trait>(
        &'life0 mut self,
        max: usize
    ) -> Pin<Box<dyn Future<Output = Option<Vec<Self::Item>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Available on crate feature async only.
Expand description

Extension methods for streams.

Required Methods§

source

fn recv_many<'life0, 'async_trait>( &'life0 mut self, max: usize ) -> Pin<Box<dyn Future<Output = Option<Vec<Self::Item>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Awaits the stream for an event to be available and returns all currently buffered events on the stream up to some max.

This method returns None if the stream has ended.

If there are no events ready on the stream this method will sleep until an event is sent or the stream is closed. When woken it will return up to max currently buffered events.

§Cancel safety

This method is cancel safe. If recv_many is used as the event in a select! statement and some other branch completes first, it is guaranteed that no messages were received on this channel.

Implementors§

source§

impl<T> OreStreamExt for T
where T: Stream + StreamExt + Send + Unpin,