macro_rules! assert_next_with_timeout {
($stream:expr) => { ... };
($stream:expr, $timeout_ms:expr) => { ... };
}
Available on crate feature
testing
only.Expand description
Asserts that the next item in a Stream
is received within a given timeout.
This macro waits for the next item from an asynchronous Stream
or, if no
item is received within the specified timeout, the macro panics.
§Parameters
$stream
: TheStream
orSubscriber
to poll for the next item.$timeout_ms
(optional): The timeout in milliseconds to wait for the next item. Defaults to 500ms if not provided.
§Example
use futures_util::{stream, StreamExt};
use matrix_sdk::assert_next_with_timeout;
let mut stream = stream::iter(vec![1, 2, 3]);
let next_item = assert_next_with_timeout!(stream, 1000); // Waits up to 1000ms
assert_eq!(next_item, 1);
// The timeout can be omitted, in which case it defaults to 500 ms.
let next_item = assert_next_with_timeout!(stream); // Waits up to 500ms
assert_eq!(next_item, 2);