Implement Into for Trait

Edit: I misread your question, but the following might be useful information anyway.

You can have a variants of send and into_response_channel that take self: Box<Self> instead of a plain self:

pub trait Request: tokio::io::AsyncRead + Send + Unpin {
    fn size(&self) -> usize;
    fn into_response_channel(self) -> tokio::sync::oneshot::Sender<String> where Self: Sized;

    fn into_response_channel_boxed(self: Box<Self>) -> tokio::sync::oneshot::Sender<String>;

    fn send(self, str: String) where Self: Sized {
        self.into_response_channel().send(str);
    }

    fn send_boxed(self: Box<Self>, str:String) {
        self.into_response_channel_boxed().send(str);
    }
}
1 Like