Handler

Trait Handler 

Source
pub trait Handler:
    Send
    + Sync
    + 'static {
    // Required methods
    fn handle<'a>(
        &'a self,
        connection: ConnectionHandle,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
    fn clone_box(&self) -> Box<dyn Handler>;
}
Expand description

Trait for handling WebSocket connections

Required Methods§

Source

fn handle<'a>( &'a self, connection: ConnectionHandle, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>

Handle a new connection

Source

fn clone_box(&self) -> Box<dyn Handler>

Clone the handler

Trait Implementations§

Source§

impl Clone for Box<dyn Handler>

Source§

fn clone(&self) -> Box<dyn Handler>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§

Source§

impl Handler for DefaultHandler

Source§

impl Handler for EchoHandler

Source§

impl<F> Handler for FnHandler<F>
where F: Fn(ConnectionHandle) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> + Send + Sync + Clone + 'static,