pub trait Reactor {
type TcpStream: AsyncRead + AsyncWrite + Send + Unpin + 'static;
// Required methods
fn register<H: Read + Write + AsSysFd + Send + 'static>(
&self,
socket: H,
) -> Result<impl AsyncRead + AsyncWrite + Send + Unpin + 'static>
where Self: Sized;
fn sleep(&self, dur: Duration) -> impl Future<Output = ()> + Send + 'static
where Self: Sized;
fn interval(
&self,
dur: Duration,
) -> impl Stream<Item = Instant> + Send + 'static
where Self: Sized;
fn tcp_connect_addr(
&self,
addr: SocketAddr,
) -> impl Future<Output = Result<Self::TcpStream>> + Send + 'static
where Self: Sized;
// Provided method
fn tcp_connect<A: AsyncToSocketAddrs + Send>(
&self,
addrs: A,
) -> impl Future<Output = Result<Self::TcpStream>> + Send
where Self: Sync + Sized { ... }
}
Expand description
A common interface for performing actions on a reactor
Required Associated Types§
Required Methods§
Sourcefn register<H: Read + Write + AsSysFd + Send + 'static>(
&self,
socket: H,
) -> Result<impl AsyncRead + AsyncWrite + Send + Unpin + 'static>where
Self: Sized,
fn register<H: Read + Write + AsSysFd + Send + 'static>(
&self,
socket: H,
) -> Result<impl AsyncRead + AsyncWrite + Send + Unpin + 'static>where
Self: Sized,
Register a synchronous handle, returning an asynchronous one
Sourcefn sleep(&self, dur: Duration) -> impl Future<Output = ()> + Send + 'staticwhere
Self: Sized,
fn sleep(&self, dur: Duration) -> impl Future<Output = ()> + Send + 'staticwhere
Self: Sized,
Sleep for the given duration
Sourcefn interval(
&self,
dur: Duration,
) -> impl Stream<Item = Instant> + Send + 'staticwhere
Self: Sized,
fn interval(
&self,
dur: Duration,
) -> impl Stream<Item = Instant> + Send + 'staticwhere
Self: Sized,
Stream that yields at every given interval
Sourcefn tcp_connect_addr(
&self,
addr: SocketAddr,
) -> impl Future<Output = Result<Self::TcpStream>> + Send + 'staticwhere
Self: Sized,
fn tcp_connect_addr(
&self,
addr: SocketAddr,
) -> impl Future<Output = Result<Self::TcpStream>> + Send + 'staticwhere
Self: Sized,
Create a TcpStream by connecting to a remote host
Provided Methods§
Sourcefn tcp_connect<A: AsyncToSocketAddrs + Send>(
&self,
addrs: A,
) -> impl Future<Output = Result<Self::TcpStream>> + Send
fn tcp_connect<A: AsyncToSocketAddrs + Send>( &self, addrs: A, ) -> impl Future<Output = Result<Self::TcpStream>> + Send
Create a TcpStream by connecting to a remote host