pub trait ServerHandler: Send {
type Request;
type Response;
// Required method
fn on_request<'life0, 'async_trait>(
&'life0 self,
ctx: RequestCtx<Self::Request, Self::Response>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn on_connect<'life0, 'async_trait>(
&'life0 self,
id: ConnectionId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn on_disconnect<'life0, 'async_trait>(
&'life0 self,
id: ConnectionId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Interface for a handler that receives connections and requests
Required Associated Types§
Required Methods§
Sourcefn on_request<'life0, 'async_trait>(
&'life0 self,
ctx: RequestCtx<Self::Request, Self::Response>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_request<'life0, 'async_trait>(
&'life0 self,
ctx: RequestCtx<Self::Request, Self::Response>,
) -> 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§
Sourcefn on_connect<'life0, 'async_trait>(
&'life0 self,
id: ConnectionId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn on_connect<'life0, 'async_trait>(
&'life0 self,
id: ConnectionId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Invoked upon a new connection becoming established.
Sourcefn on_disconnect<'life0, 'async_trait>(
&'life0 self,
id: ConnectionId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn on_disconnect<'life0, 'async_trait>(
&'life0 self,
id: ConnectionId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Invoked upon an existing connection getting dropped.