async-fuse 0.5.0

Helpers for fusing asynchronous computations.
Documentation

async-fuse

Documentation Crates Actions Status

Helpers for fusing asynchronous computations.

This is especially useful in combination with optional branches using tokio::select, where the future being polled isn't necessarily set. So instead of requiring a potentially problematic branch precondition, the future will simply be marked as pending indefinitely.

Features

  • stream - Makes Heap and Stack implement the Stream trait if they contain a stream.

Examples

This is available as the ticker example:

cargo run --example ticker
use std::time::Duration;
use tokio::time;

let sleep = async_fuse::Stack::new(time::sleep(Duration::from_millis(100)));
tokio::pin!(sleep);

for _ in 0..20usize {
    (&mut sleep).await;
    assert!(sleep.is_empty());

    println!("tick");

    sleep.set(async_fuse::Stack::new(time::sleep(Duration::from_millis(100))))
}

License: MIT/Apache-2.0