Trait perspective_server::SessionHandler

source ·
pub trait SessionHandler: Send + Sync {
    // Required method
    fn send_response<'a>(
        &'a mut self,
        msg: &'a [u8],
    ) -> impl Future<Output = Result<(), ServerError>> + Send + 'a;
}
Expand description

Use SessionHandler to implement a callback for messages emitted from a Session, to be passed to the Server::new_session constructor. Alternatively, a Session can be created from a closure instead via Server::new_session_with_callback.

                     :
 Client              :   Session
┏━━━━━━━━━━━━━━━━━━┓ :  ┏━━━━━━━━━━━━━━━━━━━┓
┃ handle_response  ┃<━━━┃ send_response (*) ┃
┃ ..               ┃ :  ┃ ..                ┃
┗━━━━━━━━━━━━━━━━━━┛ :  ┗━━━━━━━━━━━━━━━━━━━┛
                     :

Required Methods§

source

fn send_response<'a>( &'a mut self, msg: &'a [u8], ) -> impl Future<Output = Result<(), ServerError>> + Send + 'a

Dispatch a message from a Server for a the Session that took this SessionHandler instance as a constructor argument.

Object Safety§

This trait is not object safe.

Implementors§