Async stream split

Hi,

i have the following scenario. I have a Transport trait that shall implement AsyncRead and AsyncWrite:
pub trait Transport : AsyncRead + AsyncWrite { }

For this trait i have two implementation, one is based on tokio::net::TcpStream and the other on tokio_openssl::SslStream

In the end both implmentation are like the tcp one having a different new function:

pub struct TcpTransport {
    stream: TcpStream,
}

Now i wanted to implement AsyncRead and AsyncWrite that will just redirect calls to the corresponding stream, e.g.:

impl AsyncRead for TcpTransport {
  fn poll_read(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>, buf: &mut tokio::io::ReadBuf<'_>) -> std::task::Poll<std::io::Result<()>> {
    self.stream.poll_read();
  }
}

But this results in
error[E0599]: no method named 'poll_read' found for struct 'tokio::net::TcpStream' in the current scope

The poll_read method takes a Pin<&mut TcpStream>, so you must wrap the reference in a Pin.

Pin::new(&mut self.stream).poll_read(cx)

Since TcpStream is Unpin, you do not worry about the implications of using Pin, since it does not do anything for Unpin types.

Thanks. It must be
Pin::new(&mut self.get_mut().stream).poll_read(cx, buf) but you gave me the direction to go