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<'life0, 'async_trait>(
&'life0 self,
addr: SocketAddr,
) -> Pin<Box<dyn Future<Output = Result<impl AsyncIOHandle + Send>> + Send + 'async_trait>>
where Self: Sized + 'async_trait,
'life0: 'async_trait;
}
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<'life0, 'async_trait>(
&'life0 self,
addr: SocketAddr,
) -> Pin<Box<dyn Future<Output = Result<impl AsyncIOHandle + Send>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
'life0: 'async_trait,
fn tcp_connect<'life0, 'async_trait>(
&'life0 self,
addr: SocketAddr,
) -> Pin<Box<dyn Future<Output = Result<impl AsyncIOHandle + Send>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
'life0: 'async_trait,
Create a TcpStream by connecting to a remote host