[][src]Crate mrwei

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.

Structs

Future

A future waiting for the remote value set by Promise.

Promise

A struct that accepts a value and notify the corresponding future.

Waste

An error indicates either future or promise is dropped before the other end makes any actions.

Functions

pair

Creates a pair of future/promise.