pub struct MergeBounded<S> { /* private fields */ }
Expand description
A combined stream that releases values in any order that they come
§Example
use std::future::ready;
use futures::stream::{self, StreamExt};
use futures::executor::block_on;
use futures_buffered::Merge;
block_on(async {
let a = stream::once(ready(2));
let b = stream::once(ready(3));
let c = stream::once(ready(5));
let d = stream::once(ready(7));
let mut s = Merge::from_iter([a, b, c, d]);
let mut counter = 0;
while let Some(n) = s.next().await {
counter += n;
}
assert_eq!(counter, 2+3+5+7);
})
Implementations§
source§impl<S> MergeBounded<S>
impl<S> MergeBounded<S>
sourcepub fn push(&mut self, stream: S)
pub fn push(&mut self, stream: S)
Push a stream into the set.
This method adds the given stream to the set. This method will not
call poll_next
on the submitted stream. The caller must
ensure that Merge::poll_next
is called
in order to receive wake-up notifications for the given stream.
§Panics
This method will panic if the buffer is currently full. See Merge::try_push
to get a result instead
sourcepub fn try_push(&mut self, stream: S) -> Result<(), S>
pub fn try_push(&mut self, stream: S) -> Result<(), S>
Push a future into the set.
This method adds the given future to the set. This method will not
call poll
on the submitted future. The caller must
ensure that FuturesUnorderedBounded::poll_next
is called
in order to receive wake-up notifications for the given future.
§Errors
This method will error if the buffer is currently full, returning the future back