pub trait Reactor {
// Required methods
fn register<H: IO + Send + 'static>(
&self,
socket: IOHandle<H>,
) -> Result<impl AsyncIOHandle + Send>
where Self: Sized;
fn sleep(&self, dur: Duration) -> impl Future<Output = ()>
where Self: Sized;
fn interval(&self, dur: Duration) -> impl Stream<Item = Instant>
where Self: Sized;
fn tcp_connect(
&self,
addr: SocketAddr,
) -> impl Future<Output = Result<impl AsyncIOHandle + Send>> + Send
where Self: Sized;
}
Expand description
A common interface for performing actions on a reactor
Required Methods§
Sourcefn register<H: IO + Send + 'static>(
&self,
socket: IOHandle<H>,
) -> Result<impl AsyncIOHandle + Send>where
Self: Sized,
fn register<H: IO + Send + 'static>(
&self,
socket: IOHandle<H>,
) -> Result<impl AsyncIOHandle + Send>where
Self: Sized,
Register a synchronous handle, returning an asynchronous one
Sourcefn sleep(&self, dur: Duration) -> impl Future<Output = ()>where
Self: Sized,
fn sleep(&self, dur: Duration) -> impl Future<Output = ()>where
Self: Sized,
Sleep for the given duration
Sourcefn interval(&self, dur: Duration) -> impl Stream<Item = Instant>where
Self: Sized,
fn interval(&self, dur: Duration) -> impl Stream<Item = Instant>where
Self: Sized,
Stream that yields at every given interval
Sourcefn tcp_connect(
&self,
addr: SocketAddr,
) -> impl Future<Output = Result<impl AsyncIOHandle + Send>> + Sendwhere
Self: Sized,
fn tcp_connect(
&self,
addr: SocketAddr,
) -> impl Future<Output = Result<impl AsyncIOHandle + Send>> + Sendwhere
Self: Sized,
Create a TcpStream by connecting to a remote host