Skip to main content

Server

Trait Server 

Source
pub trait Server: Sized + Send {
    type Socket: Socket;

    // Required methods
    fn bind(
        options: &ServerOptions,
    ) -> impl Future<Output = Result<Self>> + Send;
    fn accept(
        &mut self,
    ) -> impl Future<Output = Option<(Self::Socket, SocketAddr)>> + Send;
    fn local_addr(&self) -> Result<SocketAddr>;

    // Provided method
    fn start(
        options: ServerOptions,
        service: Service<Handler>,
        statistics: Statistics,
        exchanger: Exchanger,
    ) -> impl Future<Output = Result<()>> + Send { ... }
}

Required Associated Types§

Required Methods§

Source

fn bind(options: &ServerOptions) -> impl Future<Output = Result<Self>> + Send

Bind the server to the specified address.

Source

fn accept( &mut self, ) -> impl Future<Output = Option<(Self::Socket, SocketAddr)>> + Send

Accept a new connection.

Source

fn local_addr(&self) -> Result<SocketAddr>

Get the local address of the listener.

Provided Methods§

Source

fn start( options: ServerOptions, service: Service<Handler>, statistics: Statistics, exchanger: Exchanger, ) -> impl Future<Output = Result<()>> + Send

Start the server.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§