ProtocolHandler

Trait ProtocolHandler 

Source
pub trait ProtocolHandler: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn can_handle(&self, buffer: &[u8]) -> bool;
    fn handle_connection(
        &self,
        conn: &mut Connection,
    ) -> Result<(), ProtocolError>;
    fn handle_read(&self, conn: &mut Connection) -> Result<(), ProtocolError>;
    fn handle_write(&self, conn: &mut Connection) -> Result<(), ProtocolError>;
    fn should_close(&self, conn: &Connection) -> bool;
}
Expand description

Trait for protocol handlers

Required Methods§

Source

fn name(&self) -> &'static str

Protocol name for identification

Source

fn can_handle(&self, buffer: &[u8]) -> bool

Detect if this protocol can handle the given connection buffer

Source

fn handle_connection(&self, conn: &mut Connection) -> Result<(), ProtocolError>

Handle a connection using this protocol

Source

fn handle_read(&self, conn: &mut Connection) -> Result<(), ProtocolError>

Handle readable events for this connection

Source

fn handle_write(&self, conn: &mut Connection) -> Result<(), ProtocolError>

Handle writable events for this connection

Source

fn should_close(&self, conn: &Connection) -> bool

Check if the connection should be closed

Implementors§