在tokio.rs文档中,我们可以看到以下代码片段
// 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);我假设split确实是Stream::split,但是我不知道这个特性如何应用于TcpStream,因为流页面没有提到TcpStream,反之亦然。
发布于 2019-05-29 07:04:35
tokio::net::TcpStream实现了AsyncRead。
split()是AsyncRead提供的方法之一
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>)
where
Self: AsyncWrite, 因此,在这种情况下,它不是您提出的问题所暗示的Stream::split,因为根据您的观察,tokio::net::TcpStream不是Stream的实现者。
https://stackoverflow.com/questions/56349398
复制相似问题