[][src]Macro tari_test_utils::collect_stream

macro_rules! collect_stream {
    ($stream:expr, take=$take:expr, timeout=$timeout:expr $(,)?) => { ... };
    ($stream:expr, timeout=$timeout:expr $(,)?) => { ... };
}

Collect $take items from a stream or timeout for Duration $timeout.

Requires the tokio runtime and should be used in an async context.


let mut rt = Runtime::new().unwrap();
let mut stream = stream::iter(1..10);
assert_eq!(rt.block_on(async { collect_stream!(stream, take=3, timeout=Duration::from_secs(1)) }), vec![1,2,3]);