futures_concurrency::stream

Trait Merge

source
pub trait Merge {
    type Item;
    type Stream: Stream<Item = Self::Item>;

    // Required method
    fn merge(self) -> Self::Stream;
}
Expand description

Combines multiple streams into a single stream of all their outputs.

Items are yielded as soon as they’re received, and the stream continues yield until both streams have been exhausted. The output ordering between streams is not guaranteed.

§Examples

use futures_concurrency::prelude::*;
use futures_lite::stream::{self, StreamExt};
use futures_lite::future::block_on;

block_on(async {
    let a = stream::once(1);
    let b = stream::once(2);
    let c = stream::once(3);
    let mut s = [a, b, c].merge();

    let mut buf = vec![];
    s.for_each(|n| buf.push(n)).await;
    buf.sort_unstable();
    assert_eq!(&buf, &[1, 2, 3]);
})

Required Associated Types§

source

type Item

The resulting output type.

source

type Stream: Stream<Item = Self::Item>

The stream type.

Required Methods§

source

fn merge(self) -> Self::Stream

Combine multiple streams into a single stream.

Implementations on Foreign Types§

source§

impl Merge for ()

source§

type Item = Infallible

source§

type Stream = Merge0

source§

fn merge(self) -> Self::Stream

source§

impl<S> Merge for Vec<S>
where S: IntoStream,

source§

impl<S, const N: usize> Merge for [S; N]
where S: IntoStream,

source§

type Item = <Merge<<S as IntoStream>::IntoStream, N> as Stream>::Item

source§

type Stream = Merge<<S as IntoStream>::IntoStream, N>

source§

fn merge(self) -> Self::Stream

source§

impl<T, A> Merge for (A,)
where A: IntoStream<Item = T>,

source§

type Item = T

source§

type Stream = Merge1<T, <A as IntoStream>::IntoStream>

source§

fn merge(self) -> Self::Stream

source§

impl<T, A, B> Merge for (A, B)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>,

source§

type Item = T

source§

type Stream = Merge2<T, <A as IntoStream>::IntoStream, <B as IntoStream>::IntoStream>

source§

fn merge(self) -> Self::Stream

source§

impl<T, A, B, C> Merge for (A, B, C)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>, C: IntoStream<Item = T>,

source§

type Item = T

source§

type Stream = Merge3<T, <A as IntoStream>::IntoStream, <B as IntoStream>::IntoStream, <C as IntoStream>::IntoStream>

source§

fn merge(self) -> Self::Stream

source§

impl<T, A, B, C, D> Merge for (A, B, C, D)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>, C: IntoStream<Item = T>, D: IntoStream<Item = T>,

source§

type Item = T

source§

type Stream = Merge4<T, <A as IntoStream>::IntoStream, <B as IntoStream>::IntoStream, <C as IntoStream>::IntoStream, <D as IntoStream>::IntoStream>

source§

fn merge(self) -> Self::Stream

source§

impl<T, A, B, C, D, E> Merge for (A, B, C, D, E)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>, C: IntoStream<Item = T>, D: IntoStream<Item = T>, E: IntoStream<Item = T>,

source§

type Item = T

source§

type Stream = Merge5<T, <A as IntoStream>::IntoStream, <B as IntoStream>::IntoStream, <C as IntoStream>::IntoStream, <D as IntoStream>::IntoStream, <E as IntoStream>::IntoStream>

source§

fn merge(self) -> Self::Stream

source§

impl<T, A, B, C, D, E, F> Merge for (A, B, C, D, E, F)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>, C: IntoStream<Item = T>, D: IntoStream<Item = T>, E: IntoStream<Item = T>, F: IntoStream<Item = T>,

source§

type Item = T

source§

type Stream = Merge6<T, <A as IntoStream>::IntoStream, <B as IntoStream>::IntoStream, <C as IntoStream>::IntoStream, <D as IntoStream>::IntoStream, <E as IntoStream>::IntoStream, <F as IntoStream>::IntoStream>

source§

fn merge(self) -> Self::Stream

source§

impl<T, A, B, C, D, E, F, G> Merge for (A, B, C, D, E, F, G)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>, C: IntoStream<Item = T>, D: IntoStream<Item = T>, E: IntoStream<Item = T>, F: IntoStream<Item = T>, G: IntoStream<Item = T>,

source§

impl<T, A, B, C, D, E, F, G, H> Merge for (A, B, C, D, E, F, G, H)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>, C: IntoStream<Item = T>, D: IntoStream<Item = T>, E: IntoStream<Item = T>, F: IntoStream<Item = T>, G: IntoStream<Item = T>, H: IntoStream<Item = T>,

source§

impl<T, A, B, C, D, E, F, G, H, I> Merge for (A, B, C, D, E, F, G, H, I)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>, C: IntoStream<Item = T>, D: IntoStream<Item = T>, E: IntoStream<Item = T>, F: IntoStream<Item = T>, G: IntoStream<Item = T>, H: IntoStream<Item = T>, I: IntoStream<Item = T>,

source§

impl<T, A, B, C, D, E, F, G, H, I, J> Merge for (A, B, C, D, E, F, G, H, I, J)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>, C: IntoStream<Item = T>, D: IntoStream<Item = T>, E: IntoStream<Item = T>, F: IntoStream<Item = T>, G: IntoStream<Item = T>, H: IntoStream<Item = T>, I: IntoStream<Item = T>, J: IntoStream<Item = T>,

source§

impl<T, A, B, C, D, E, F, G, H, I, J, K> Merge for (A, B, C, D, E, F, G, H, I, J, K)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>, C: IntoStream<Item = T>, D: IntoStream<Item = T>, E: IntoStream<Item = T>, F: IntoStream<Item = T>, G: IntoStream<Item = T>, H: IntoStream<Item = T>, I: IntoStream<Item = T>, J: IntoStream<Item = T>, K: IntoStream<Item = T>,

source§

impl<T, A, B, C, D, E, F, G, H, I, J, K, L> Merge for (A, B, C, D, E, F, G, H, I, J, K, L)
where A: IntoStream<Item = T>, B: IntoStream<Item = T>, C: IntoStream<Item = T>, D: IntoStream<Item = T>, E: IntoStream<Item = T>, F: IntoStream<Item = T>, G: IntoStream<Item = T>, H: IntoStream<Item = T>, I: IntoStream<Item = T>, J: IntoStream<Item = T>, K: IntoStream<Item = T>, L: IntoStream<Item = T>,

Implementors§