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§
Sourcefn can_handle(&self, buffer: &[u8]) -> bool
fn can_handle(&self, buffer: &[u8]) -> bool
Detect if this protocol can handle the given connection buffer
Sourcefn handle_connection(&self, conn: &mut Connection) -> Result<(), ProtocolError>
fn handle_connection(&self, conn: &mut Connection) -> Result<(), ProtocolError>
Handle a connection using this protocol
Sourcefn handle_read(&self, conn: &mut Connection) -> Result<(), ProtocolError>
fn handle_read(&self, conn: &mut Connection) -> Result<(), ProtocolError>
Handle readable events for this connection
Sourcefn handle_write(&self, conn: &mut Connection) -> Result<(), ProtocolError>
fn handle_write(&self, conn: &mut Connection) -> Result<(), ProtocolError>
Handle writable events for this connection
Sourcefn should_close(&self, conn: &Connection) -> bool
fn should_close(&self, conn: &Connection) -> bool
Check if the connection should be closed