pub trait ServerHandler: Send {
    type Request;
    type Response;
    type LocalData: Send;

    // Required method
    fn on_request<'life0, 'async_trait>(
        &'life0 self,
        ctx: ServerCtx<Self::Request, Self::Response, Self::LocalData>
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn on_accept<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: ConnectionCtx<'life1, Self::LocalData>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Interface for a handler that receives connections and requests

Required Associated Types§

source

type Request

Type of data received by the server

source

type Response

Type of data sent back by the server

source

type LocalData: Send

Type of data to store locally tied to the specific connection

Required Methods§

source

fn on_request<'life0, 'async_trait>( &'life0 self, ctx: ServerCtx<Self::Request, Self::Response, Self::LocalData> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Invoked upon receiving a request from a client. The server should process this request, which can be found in ctx, and send one or more replies in response.

Provided Methods§

source

fn on_accept<'life0, 'life1, 'async_trait>( &'life0 self, ctx: ConnectionCtx<'life1, Self::LocalData> ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Invoked upon a new connection becoming established.

Note

This can be useful in performing some additional initialization on the connection’s local data prior to it being used anywhere else.

Implementors§