I am trying to implement write_all which forwards the call to inner TcpStream
pub struct ByteStream<R>(pub R);
impl ByteStream<tokio::net::TcpStream> {
fn write_all<'a>(&'a mut self, src: &'a [u8]) -> tokio_io::io::write_all::WriteAll<'a, TcpStream> {
self.0.write_all(src)
}
}
It ends with compliation error because WriteAll
is private
error[E0603]: module `io` is private
|
344 | fn write_all<'a>(&'a mut self, src: &'a [u8]) -> tokio_io::io::write_all::WriteAll<'a, TcpStream> {
Hence I have to await
in the function
impl ByteStream<tokio::net::TcpStream> {
async fn write_all<'a>(&'a mut self, src: &'a [u8]) -> Result<(), Error> {
self.0.write_all(src).await?;
Ok(())
}
}
Is there a simple way to implement the method without await
?