#futures #promise #async

mrwei

A simple library that implements the common promise primitive for rust based on std future

1 unstable release

0.1.0 Jan 6, 2021

#336 in Asynchronous

MIT license

17KB
369 lines

mrwei

A simple library that implements the common promise primitive for rust based on std future.

Documentation Crates.io


lib.rs:

A simple crate to create a promise/future pair.

Promise/future pair is a very common pattern in other languages. You can think it as a oneshot channel, but it's only one way future. The crate is also executor independent.

Usage

Include it in cargo dependency:

mrwei = "0.1"

You can use pair to create an instance of future and promise.

let (f, p) = mrwei::pair::<Type>();

You probably need to either move the future or the promise to another thread and await or set a value respectively. When the promise is offered a value, the corresponding future will also be notified.

No runtime deps