perspective_server

Trait 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.

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.

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§