Skip to main content

ServerTransport

Trait ServerTransport 

Source
pub trait ServerTransport: Send + Sync {
    // Required methods
    fn address(&self) -> &ServerAddress;
    fn accept(&self, cx: &mut Cx) -> Result<Box<dyn ConnectionTransport>>;
    fn shutdown(&self, cx: &mut Cx) -> Result<()>;
    fn accept_timeout(
        &self,
        cx: &mut Cx,
        timeout: Duration,
    ) -> Result<Option<Box<dyn ConnectionTransport>>>;
}
Expand description

Listening side of a transport: binds an address and accepts connections.

Required Methods§

Source

fn address(&self) -> &ServerAddress

Returns the address this transport is bound to.

Source

fn accept(&self, cx: &mut Cx) -> Result<Box<dyn ConnectionTransport>>

Blocks until a connection arrives and returns it.

Source

fn shutdown(&self, cx: &mut Cx) -> Result<()>

Shuts down the listener and releases its resources.

Source

fn accept_timeout( &self, cx: &mut Cx, timeout: Duration, ) -> Result<Option<Box<dyn ConnectionTransport>>>

Accepts a connection, returning None if timeout elapses first.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§