ruyi 0.1.6

An event-driven framework for non-blocking, asynchronous I/O in Rust
Documentation
use std::borrow::ToOwned;

use reactor::Task;
use service::tcp::Session;

pub trait Handler {
    fn handle(&mut self, session: Session) -> Task;
}

pub trait ToHandler {
    type Handler: Handler;

    fn to_handler(&self) -> Self::Handler;
}

impl<H> ToHandler for H
where
    H: Handler + ToOwned<Owned = Self>,
{
    type Handler = Self;

    #[inline]
    fn to_handler(&self) -> Self::Handler {
        self.to_owned()
    }
}