promises 0.2.0

Effective, simple, lightweight Javascript promises in Rust
Documentation
  • Coverage
  • 100%
    12 out of 12 items documented0 out of 11 items with examples
  • Size
  • Source code size: 14.22 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.52 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • SnirkImmington/rust-promises
    1 2 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • SnirkImmington

rust-promises

This library seeks to fully, effectively and simply recreate lightweight Javascript-style promises in Rust.

rust-promises offers all the features of Ecmascript 6 promises plus a few Rust methods from Result<T, E>, implemented using the std::thread API and Rust's asyncronous Sender and Receiver.

Examples

TODO (after adding some Result methods to Promise).

Why?

Promises are an excellent building block for asyncronous programming. They're a great way to build an asyncronous library, and also a small dependency for existing code.

Javascript's promises were adapted from promises in a programming language called E, which has a very powerful distributed computing architecture using message passing.

Rust's std::sync::mpsc::{Sender, Receiver} provide a way to build such an architecture (and promises) from Rust's safe threading systems.

Oh great, another promise library

There are currently 5 asyncronous libraries on crates.io which offer promises or futures. However they all have problems:

  • They are all in beta and unstable, with versions < 0.5 (like this library right now...)
  • Some of them are larger async libraries. They require programming within event loops, or are designed for specific scenarios. If you want a whole async library for a specific type of programming, go use those.
  • The rest are variations on the promise concept, i.e. returning a (Future, Promise) pair from Promise::new(). If you know how to use that, go to those libraries, I guess.