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

#1949 in Asynchronous

Download history 105/week @ 2023-11-18 151/week @ 2023-11-25 37/week @ 2023-12-02 54/week @ 2023-12-09 64/week @ 2023-12-16 53/week @ 2023-12-23 19/week @ 2023-12-30 63/week @ 2024-01-06 67/week @ 2024-01-13 59/week @ 2024-01-20 41/week @ 2024-01-27 30/week @ 2024-02-03 115/week @ 2024-02-10 146/week @ 2024-02-17 72/week @ 2024-02-24 76/week @ 2024-03-02

420 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