9 releases

Uses old Rust 2015

0.1.7 May 4, 2016
0.1.6 Apr 2, 2016
0.1.5 Dec 22, 2015
0.1.4 Aug 16, 2015
0.0.1 Mar 31, 2015

#26 in #future

Download history 253/week @ 2021-05-30 227/week @ 2021-06-06 256/week @ 2021-06-13 259/week @ 2021-06-20 497/week @ 2021-06-27 439/week @ 2021-07-04 327/week @ 2021-07-11 346/week @ 2021-07-18 476/week @ 2021-07-25 352/week @ 2021-08-01 320/week @ 2021-08-08 327/week @ 2021-08-15 287/week @ 2021-08-22 387/week @ 2021-08-29 428/week @ 2021-09-05 631/week @ 2021-09-12

1,410 downloads per month
Used in 8 crates (4 directly)

MIT license

125KB
2.5K SLoC

Eventual - Futures & Streams for Rust

Eventual provides a Future & Stream abstraction for Rust as well as a number of computation builders to operate on them.

Build Status

Usage

To use Eventual, first add this to your Cargo.toml:

[dependencies.eventual]
git = "https://github.com/carllerche/eventual"

Then, add this to your crate root:

extern crate eventual;

lib.rs:

Composable primitives for asynchronous computations

The async module contains utilities for managing asynchronous computations. These utilities are primarily based around Future and Stream types as well as functions that allow composing computations on these types.

Future

A Future is a proxy representing the result of a computation which may not be complete. The computation may be running concurrently in another thread or may be triggered upon completion of an asynchronous callback. One way to think of a Future is as a Result where the value is asynchronously computed.

For example:

use eventual::*;

// Run a computation in another thread
let future1 = Future::spawn(|| {
    // Represents an expensive computation, but for now just return a
    // number
    42
});

// Run another computation
let future2 = Future::spawn(|| {
    // Another expensive computation
    18
});

let res = join((
        future1.map(|v| v * 2),
        future2.map(|v| v + 5)))
    .and_then(|(v1, v2)| Ok(v1 - v2))
    .await().unwrap();

assert_eq!(61, res);

Stream

A Stream is like a Future, except that instead of representing a single value, it represents a sequence of values.

Dependencies

~560KB
~11K SLoC