Macro async_stream::try_stream [−][src]
Asynchronous fallible stream
See crate documentation for more details.
Examples
use tokio::net::{TcpListener, TcpStream}; use async_stream::try_stream; use futures_core::stream::Stream; use std::io; use std::net::SocketAddr; fn bind_and_accept(addr: SocketAddr) -> impl Stream<Item = io::Result<TcpStream>> { try_stream! { let mut listener = TcpListener::bind(addr).await?; loop { let (stream, addr) = listener.accept().await?; println!("received on {:?}", addr); yield stream; } } }