Reputation: 1405
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.
Upvotes: 4
Views: 437
Reputation: 13567
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
.
Upvotes: 3