Skip to main content

Reactor

Trait Reactor 

Source
pub trait Reactor: Driver {
    // Required methods
    fn tcp_connect(&self, addr: SocketAddr, cfg: SharedCfg) -> Receiver<Io> ⓘ;
    fn unix_connect(&self, addr: PathBuf, cfg: SharedCfg) -> Receiver<Io> ⓘ;
    fn from_tcp_stream(&self, stream: TcpStream, cfg: SharedCfg) -> Result<Io>;
    fn from_unix_stream(&self, _: UnixStream, _: SharedCfg) -> Result<Io>;

    // Provided methods
    fn tcp_listener(&self, sock: TcpListener) -> Result<Listener> { ... }
    fn is_tcp_listener_supported(&self) -> bool { ... }
}
Expand description

Runtime reactor used for network connection and transport operations.

Required Methods§

Source

fn tcp_connect(&self, addr: SocketAddr, cfg: SharedCfg) -> Receiver<Io> ⓘ

Starts an asynchronous TCP connection.

Source

fn unix_connect(&self, addr: PathBuf, cfg: SharedCfg) -> Receiver<Io> ⓘ

Starts an asynchronous Unix domain socket connection.

Source

fn from_tcp_stream(&self, stream: TcpStream, cfg: SharedCfg) -> Result<Io>

Converts a standard-library TCP stream into an [Io] value.

The reactor does not change TCP_NODELAY; the stream keeps the value it already has. Callers that need low latency must call stream.set_nodelay(true) before converting the stream, unless the option is already set, for example inherited from a listener with TCP_NODELAY enabled on Linux and macOS.

Source

fn from_unix_stream(&self, _: UnixStream, _: SharedCfg) -> Result<Io>

Converts a standard-library Unix stream into an [Io] value.

Provided Methods§

Source

fn tcp_listener(&self, sock: TcpListener) -> Result<Listener>

Registers a TCP listener with the reactor.

The default implementation returns an io::ErrorKind::Unsupported error.

Source

fn is_tcp_listener_supported(&self) -> bool

Returns true if tcp_listener is supported.

The default implementation returns false.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Reactor for ntex_net::polling::Reactor

Source§

impl Reactor for ntex_net::uring::Reactor

Source§

impl Reactor for ntex_net::tokio::Reactor