[][src]Trait hydrogen::Handler

pub trait Handler {
    fn on_server_created(&mut self, fd: RawFd);
fn on_new_connection(&mut self, fd: RawFd) -> Arc<UnsafeCell<dyn Stream>>;
fn on_data_received(&mut self, socket: HydrogenSocket, buf: Vec<u8>);
fn on_connection_removed(&mut self, fd: RawFd, err: Error); }

Events reported to lib consumer.

Required methods

fn on_server_created(&mut self, fd: RawFd)

This method is called once the listening RawFd has been created.

It should be used to set/remove any flags on the underlying RawFd before listen is called on the fd.

fn on_new_connection(&mut self, fd: RawFd) -> Arc<UnsafeCell<dyn Stream>>

This method is called whenever accept returns a new TCP connection.

The returned trait object is added to the connection pool and the epoll interest list.

fn on_data_received(&mut self, socket: HydrogenSocket, buf: Vec<u8>)

This method is called whenever the recv call returns an Ok(_) result.

fn on_connection_removed(&mut self, fd: RawFd, err: Error)

This method is called after a stream has been removed from the connection poll and epoll interest list, with the std::io::Error as the reason removed.

At the time of this call, the underlying fd has been shutdown and closed. No system level shutdown is needed, only application level cleanup.

Loading content...

Implementors

Loading content...