[][src]Crate 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))))
}

Structs

Heap

Fusing adapter that is capable of polling an interior value that is being fused using a custom polling function.

Stack

Fusing adapter for fusing a value on the stack.