Trait distant_net::server::ServerHandler
source · pub trait ServerHandler: Send {
type Request;
type Response;
type LocalData: Send;
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 on_accept<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: ConnectionCtx<'life1, Self::LocalData>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + '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: ServerCtx<Self::Request, Self::Response, Self::LocalData>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
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,
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_accept<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: ConnectionCtx<'life1, Self::LocalData>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
fn on_accept<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: ConnectionCtx<'life1, Self::LocalData>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + '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.