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

#2059 in Asynchronous

Download history 95/week @ 2024-08-26 93/week @ 2024-09-02 83/week @ 2024-09-09 68/week @ 2024-09-16 134/week @ 2024-09-23 88/week @ 2024-09-30 25/week @ 2024-10-07 90/week @ 2024-10-14 131/week @ 2024-10-21 122/week @ 2024-10-28 139/week @ 2024-11-04 32/week @ 2024-11-11 76/week @ 2024-11-18 118/week @ 2024-11-25 161/week @ 2024-12-02 221/week @ 2024-12-09

584 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.9–1.2MB
~20K SLoC