#futures #async #future #stream #merge

futures-stream-select-all

A futures library adapter for merging the output of several streams

1 unstable release

Uses old Rust 2015

0.1.2 Jun 11, 2017

#21 in #merge

Download history 21/week @ 2020-12-31 23/week @ 2021-01-07 97/week @ 2021-01-14 28/week @ 2021-01-21 138/week @ 2021-01-28 179/week @ 2021-02-04 155/week @ 2021-02-11 216/week @ 2021-02-18 119/week @ 2021-02-25 97/week @ 2021-03-04 31/week @ 2021-03-11 72/week @ 2021-03-18 65/week @ 2021-03-25 23/week @ 2021-04-01 130/week @ 2021-04-08

378 downloads per month

MIT license

4KB
61 lines

futures-stream-select-all

A futures library adapter for merging the output of several streams.

It implements a binary-tree structure to efficiently perform select for any amount of undelying streams.

Usage

First, add this to your Cargo.toml:

[dependencies]
futures-stream-select-all = "0.1"

Next, add this to your crate:

extern crate futures-stream-select-all;

use futures_stream_select_all::select_all;

Example

    use futures::{stream, Stream, Future};
    use futures_stream_select_all::select_all;

    let stream_a = stream::iter(vec![Ok(0), Ok(1)]);
    let stream_b = stream::iter(vec![Ok(2), Ok(3), Ok(4)]);
    let stream_c = stream::iter(vec![Ok(5)]);

    let mut values = select_all::<_, _, ()>(vec![stream_a, stream_b, stream_c])
        .collect()
        .wait()
        .unwrap();
    values.sort();
    assert_eq!(values, vec![0, 1, 2, 3, 4, 5]);

License

futures-stream-select-all is primarily distributed under the terms of the MIT license.

See LICENSE-MIT for details.

Dependencies

~43KB