pub trait IoHandler<Message>: Send + Sync{
// Provided methods
fn initialize(&self, _io: &IoContext<Message>) { ... }
fn timeout(&self, _io: &IoContext<Message>, _timer: TimerToken) { ... }
fn message(&self, _io: &IoContext<Message>, _message: &Message) { ... }
fn stream_hup(&self, _io: &IoContext<Message>, _stream: StreamToken) { ... }
fn stream_readable(&self, _io: &IoContext<Message>, _stream: StreamToken) { ... }
fn stream_writable(&self, _io: &IoContext<Message>, _stream: StreamToken) { ... }
fn register_stream(
&self,
_stream: StreamToken,
_reg: Token,
_event_loop: &Poll
) { ... }
fn update_stream(
&self,
_stream: StreamToken,
_reg: Token,
_event_loop: &Poll
) { ... }
fn deregister_stream(&self, _stream: StreamToken, _event_loop: &Poll) { ... }
}
Expand description
Generic IO handler.
All the handler function are called from within IO event loop.
Message
type is used as notification data
Provided Methods§
sourcefn initialize(&self, _io: &IoContext<Message>)
fn initialize(&self, _io: &IoContext<Message>)
Initialize the handler
sourcefn timeout(&self, _io: &IoContext<Message>, _timer: TimerToken)
fn timeout(&self, _io: &IoContext<Message>, _timer: TimerToken)
Timer function called after a timeout created with HandlerIo::timeout
.
sourcefn message(&self, _io: &IoContext<Message>, _message: &Message)
fn message(&self, _io: &IoContext<Message>, _message: &Message)
Called when a broadcasted message is received. The message can only be sent from a different IO handler.
sourcefn stream_hup(&self, _io: &IoContext<Message>, _stream: StreamToken)
fn stream_hup(&self, _io: &IoContext<Message>, _stream: StreamToken)
Called when an IO stream gets closed
sourcefn stream_readable(&self, _io: &IoContext<Message>, _stream: StreamToken)
fn stream_readable(&self, _io: &IoContext<Message>, _stream: StreamToken)
Called when an IO stream can be read from
sourcefn stream_writable(&self, _io: &IoContext<Message>, _stream: StreamToken)
fn stream_writable(&self, _io: &IoContext<Message>, _stream: StreamToken)
Called when an IO stream can be written to
sourcefn register_stream(&self, _stream: StreamToken, _reg: Token, _event_loop: &Poll)
fn register_stream(&self, _stream: StreamToken, _reg: Token, _event_loop: &Poll)
Register a new stream with the event loop
sourcefn update_stream(&self, _stream: StreamToken, _reg: Token, _event_loop: &Poll)
fn update_stream(&self, _stream: StreamToken, _reg: Token, _event_loop: &Poll)
Re-register a stream with the event loop
sourcefn deregister_stream(&self, _stream: StreamToken, _event_loop: &Poll)
fn deregister_stream(&self, _stream: StreamToken, _event_loop: &Poll)
Deregister a stream. Called when stream is removed from event loop