Expand description

A module to simplify selecting between a shutdown signal and a stream.

The ShutdownStream type can be used to replace this pattern:

loop {
    select! {
        _ = shutdown => break,
        item = stream.next() => { /* actual logic */ },
    }
}

by this one:

let mut shutdown_stream = ShutdownStream::new(shutdown, stream);

while let Some(item) = shutdown_stream.next().await {
    /* actual logic */
}

Structs

A stream with a shutdown.