I have a custom socket that implements AsyncWrite
and AsyncRead
. I'd like to store a dyn to this socket, but I'd like to use both AsyncWrite/Read
, like this:
#[derive(Clone)]
pub struct AsyncTransporter {
stream: Arc<dyn AsyncRead + AsyncWrite>,
}
but this is not supported.
60 | stream: Arc<dyn AsyncRead + AsyncWrite>,
| --------- ^^^^^^^^^^ additional non-auto trait
| |
| first non-auto trait
|
= help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: tokio::io::AsyncRead + tokio::io::AsyncWrite {}`
If I do trait NewTrait: tokio::io::AsyncRead + tokio::io::AsyncWrite {}
, how will the methods of both traits be implemented?