timeout_stream

Function timeout_stream 

Source
pub fn timeout_stream(
    duration: Duration,
) -> impl Stream<Item = ()> + Send + Unpin
Expand description

Create a stream that completes after a delay (alias for delayed_stream)

This is useful for timeouts or delayed actions.

ยงExample

use hojicha_runtime::stream_builders::timeout_stream;
use std::time::Duration;
use futures::StreamExt;

let mut stream = timeout_stream(Duration::from_millis(10));
let result = stream.next().await;
assert_eq!(result, Some(()));