[−][src]Trait libtelnet_rs::TelnetEvents
A trait for event handlers of Telnet events.
Example
struct TelEvent; impl TelnetEvents for TelEvent { fn on_iac(&self, command: u8) { println!("IAC: {}", command); } fn on_data(&self, size: usize, buffer: Vec<u8>) { println!( "Data: {} byte(s) | {}", size, String::from_utf8(buffer).unwrap() ); } fn on_send(&self, size: usize, buffer: Vec<u8>) { println!("Send: {} byte(s) | {:?}", size, buffer); } fn on_negotiation(&self, command: u8, option: u8) { println!("Negotiate: {} {}", command, option); } fn on_subnegotiation(&self, option: u8, size: usize, buffer: Vec<u8>) { match String::from_utf8(buffer.clone()) { Ok(text) => { println!("Subnegotiation: {} - {} byte(s) | {}", option, size, text); } Err(_) => { println!( "Subnegotiation: {} - {} byte(s) | {:?}", option, size, buffer ); } } } }