In the tokio.rs docs we see the following snippet
// split the socket stream into readable and writable parts
let (reader, writer) = socket.split();
// copy bytes from the reader into the writer
let amount = io::copy(reader, writer);
I am assuming that split is indeed Stream::split, but I can't figure out how this trait applies to TcpStream given that the stream page doesn't mention TcpStream and vice versa.
tokio::net::TcpStream implements AsyncRead.
One of the provided methods from AsyncRead is split():
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>)
where
Self: AsyncWrite,
So in this case it isn't Stream::split as your question suggested because as per your observation tokio::net::TcpStream isn't an implementor of Stream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With