Reactor

Trait Reactor 

Source
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§

Source

type TcpStream: AsyncRead + AsyncWrite + Send + Unpin + 'static

The type representing a TCP stream (after tcp_connect) for this reactor

Required Methods§

Source

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

Source

fn sleep(&self, dur: Duration) -> impl Future<Output = ()> + Send + 'static
where Self: Sized,

Sleep for the given duration

Source

fn interval( &self, dur: Duration, ) -> impl Stream<Item = Instant> + Send + 'static
where Self: Sized,

Stream that yields at every given interval

Source

fn tcp_connect_addr( &self, addr: SocketAddr, ) -> impl Future<Output = Result<Self::TcpStream>> + Send + 'static
where Self: Sized,

Create a TcpStream by connecting to a remote host

Provided Methods§

Source

fn tcp_connect<A: AsyncToSocketAddrs + Send>( &self, addrs: A, ) -> impl Future<Output = Result<Self::TcpStream>> + Send
where Self: Sync + Sized,

Create a TcpStream by connecting to a remote host

Implementors§