pub trait ListenExt: Stream {
fn sleep_on_error(self, delay: Duration) -> SleepOnError<Self>
where
Self: Sized,
{ ... }
fn listen(self, max_connections: usize) -> Listen<Self>
where
Self: Sized,
Self::Item: IntoFuture<Item = (), Error = ()>,
{ ... }
}
Expand description
An extension trait that provides necessary combinators for turning
a stream of accept()
events into a full-featured connection listener
Usually both sleep_on_error
and listen
commbinators are used in pair
with .map()
in-between. See examples for full-featured example.
Provided Methods
sourcefn sleep_on_error(self, delay: Duration) -> SleepOnError<Self>where
Self: Sized,
fn sleep_on_error(self, delay: Duration) -> SleepOnError<Self>where
Self: Sized,
Turns a listening stream that you can get from TcpListener::incoming
into a stream that supresses errors and sleeps on resource shortage,
effectively allowing listening stream to resume on error.