Trait ProtocolExtension

Source
pub trait ProtocolExtension: Debug {
    // Required methods
    fn get_id(&self) -> u8;
    fn get_supported_packets(&self) -> &'static [u8] ;
    fn encode(&self) -> Bytes;
    fn handle_handshake<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        read: &'life1 mut dyn WebSocketRead,
        write: &'life2 LockedWebSocketWrite,
    ) -> Pin<Box<dyn Future<Output = Result<(), WispError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn handle_packet<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        packet: Bytes,
        read: &'life1 mut dyn WebSocketRead,
        write: &'life2 LockedWebSocketWrite,
    ) -> Pin<Box<dyn Future<Output = Result<(), WispError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn box_clone(&self) -> Box<dyn ProtocolExtension + Sync + Send>;
}
Expand description

A Wisp protocol extension.

See the docs.

Required Methods§

Source

fn get_id(&self) -> u8

Get the protocol extension ID.

Source

fn get_supported_packets(&self) -> &'static [u8]

Get the protocol extension’s supported packets.

Used to decide whether to call the protocol extension’s packet handler.

Source

fn encode(&self) -> Bytes

Encode self into Bytes.

Source

fn handle_handshake<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, read: &'life1 mut dyn WebSocketRead, write: &'life2 LockedWebSocketWrite, ) -> Pin<Box<dyn Future<Output = Result<(), WispError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Handle the handshake part of a Wisp connection.

This should be used to send or receive data before any streams are created.

Source

fn handle_packet<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, packet: Bytes, read: &'life1 mut dyn WebSocketRead, write: &'life2 LockedWebSocketWrite, ) -> Pin<Box<dyn Future<Output = Result<(), WispError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Handle receiving a packet.

Source

fn box_clone(&self) -> Box<dyn ProtocolExtension + Sync + Send>

Clone the protocol extension.

Implementors§