Crate woven

Crate woven 

Source
Expand description

A simple set of async combinators, usable in a no_std, no_alloc environment.

§Technical Note

Because of it’s simplicity, Woven doesn’t implement granular wakers, so an executer has no way of knowing which task woke it. This usually leads to all the combined futures being polled again, regardless of which one actually woke the executor. It’s up to you whether this is acceptable or not.

§Usage

See cassette for the executor used in the examples.

§Join

use woven::Join;

cassette::block_on(async {
    let future1 = async { 1 };
    let future2 = async { 2 };
    let future3 = async { 3 };

    let result = (future1, future2, future3).join().await;
    assert_eq!(result, (1, 2, 3));
});

§Race

use woven::{Race, Either3};

cassette::block_on(async {
    let future1 = async { 1 };
    let future2 = async { 2 };
    let future3 = async { 3 };

    let result = (future1, future2, future3).race().await;
    assert_eq!(result, Either3::First(1)); // If multiple futures complete at the same time, the first one is returned.
});

§Race Same

use woven::RaceSame;

cassette::block_on(async {
    let future1 = async { 1 };
    let future2 = async { 2 };
    let future3 = async { 3 };

    let result = (future1, future2, future3).race_same().await;
    assert_eq!(result, 1); // If multiple futures complete at the same time, the first one is returned.
});

Enums§

Either
An enum representing the output of a Race operation.
Either3
An enum representing the output of a Race operation.
Either4
An enum representing the output of a Race operation.
Either5
An enum representing the output of a Race operation.
Either6
An enum representing the output of a Race operation.
Either7
An enum representing the output of a Race operation.
Either8
An enum representing the output of a Race operation.
Either9
An enum representing the output of a Race operation.
Either10
An enum representing the output of a Race operation.
Either11
An enum representing the output of a Race operation.
Either12
An enum representing the output of a Race operation.
Either13
An enum representing the output of a Race operation.
Either14
An enum representing the output of a Race operation.
Either15
An enum representing the output of a Race operation.
Either16
An enum representing the output of a Race operation.

Traits§

Join
Combine multiple futures into one that resolves when all are done.
Race
Combine multiple futures into one that resolves when any single one is done.
RaceSame
Combine multiple futures with the same output into one that resolves when any single one is done.