Trait ServerHandler

pub trait ServerHandler<T>
where T: Transport,
{ // Required methods fn on_one_way( &mut self, sender: &ServerSender<T>, ordinal: u64, buffer: <T as Transport>::RecvBuffer, ) -> impl Future<Output = ()> + Send; fn on_two_way( &mut self, sender: &ServerSender<T>, ordinal: u64, buffer: <T as Transport>::RecvBuffer, responder: Responder, ) -> impl Future<Output = ()> + Send; }
Expand description

A type which handles incoming events for a server.

The futures returned by on_one_way and on_two_way are required to be Send. See LocalServerHandler for a version of this trait which does not require the returned futures to be Send.

Required Methods§

fn on_one_way( &mut self, sender: &ServerSender<T>, ordinal: u64, buffer: <T as Transport>::RecvBuffer, ) -> impl Future<Output = ()> + Send

Handles a received one-way server message.

The server cannot handle more messages until on_one_way completes. If on_one_way may block, perform asynchronous work, or take a long time to process a message, it should offload work to an async task.

fn on_two_way( &mut self, sender: &ServerSender<T>, ordinal: u64, buffer: <T as Transport>::RecvBuffer, responder: Responder, ) -> impl Future<Output = ()> + Send

Handles a received two-way server message.

The server cannot handle more messages until on_two_way completes. If on_two_way may block, perform asynchronous work, or take a long time to process a message, it should offload work to an async task.

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§

§

impl<P, H, T> ServerHandler<T> for ServerHandlerAdapter<P, H>
where P: DispatchServerMessage<H, T>, T: Transport,