pub trait Server: Send {
    type Request: DeserializeOwned + Send + Sync;
    type Response: Serialize + Send;
    type LocalData: Send + Sync;

    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
        'life0: 'async_trait,
        Self: 'async_trait
; fn config(&self) -> ServerConfig { ... } fn on_accept<'life0, 'life1, 'async_trait>(
        &'life0 self,
        local_data: &'life1 mut Self::LocalData
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: Sync + 'async_trait
, { ... } }
Expand description

Interface for a general-purpose server that receives requests to handle

Required Associated Types

Type of data received by the server

Type of data sent back by the server

Type of data to store locally tied to the specific connection

Required Methods

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

Returns configuration tied to server instance

Invoked immediately on server start, being provided the raw listener to use (untyped transport), and returning the listener when ready to start (enabling servers that need to tweak a listener to do so) Invoked upon a new connection becoming established, which provides a mutable reference to the data created for the connection. This can be useful in performing some additional initialization on the data prior to it being used anywhere else.

Implementors