use async_stream::stream; use tokio::sync::mpsc::{self, UnboundedSender}; use tokio_stream::Stream; pub fn unbounded_channel_stream() -> (UnboundedSender, impl Stream) { let (tx, mut rx) = mpsc::unbounded_channel(); let stream = stream! { while let Some(item) = rx.recv().await { yield item; } }; (tx, stream) }