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

#2068 in Asynchronous

Download history 131/week @ 2024-07-21 120/week @ 2024-07-28 65/week @ 2024-08-04 91/week @ 2024-08-11 72/week @ 2024-08-18 95/week @ 2024-08-25 93/week @ 2024-09-01 87/week @ 2024-09-08 69/week @ 2024-09-15 132/week @ 2024-09-22 84/week @ 2024-09-29 34/week @ 2024-10-06 87/week @ 2024-10-13 127/week @ 2024-10-20 117/week @ 2024-10-27 153/week @ 2024-11-03

486 downloads per month
Used in 4 crates (2 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

~0.8–1.2MB
~19K SLoC