#futures #ert

ert

A combinator to control future execution order

4 releases

0.2.2 Sep 1, 2020
0.2.1 Jun 29, 2020
0.2.0 Mar 19, 2020
0.1.0 Sep 29, 2019

#103 in Asynchronous

Download history 377/week @ 2020-11-02 463/week @ 2020-11-09 437/week @ 2020-11-16 258/week @ 2020-11-23 357/week @ 2020-11-30 395/week @ 2020-12-07 378/week @ 2020-12-14 417/week @ 2020-12-21 323/week @ 2020-12-28 438/week @ 2021-01-04 343/week @ 2021-01-11 426/week @ 2021-01-18 404/week @ 2021-01-25 404/week @ 2021-02-01 284/week @ 2021-02-08 275/week @ 2021-02-15

1,308 downloads per month

MIT license

10KB
174 lines

ert

A combinator to control future execution order.

Latest version Documentation License Actions Status

struct Data {
    file: String,
    tag: usize,
    value: usize,
}

#[tokio::main]
async fn main() {
    // Stream of `Data` coming over TCP.
    let f = tcp_stream()
        .map(|d| {
            let tag = d.tag;
            let f = async move {
                let v = read_value_from_file(&d.file).await;
                write_value_to_file(&d.file, v + d.value).await;
            };
            f.via_g(tag)
        })
        .buffer_unordered(100)
        .for_each(|_| async {});

    f.await;
}

order

Dependencies

~2.5MB
~44K SLoC