rust - tokio::net::TcpStream 是如何实现 tokio::prelude::Stream 的?
问题描述
在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
解决方案
tokio::net::TcpStream
实现AsyncRead
。
提供的方法之一AsyncRead
是split()
:
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>)
where
Self: AsyncWrite,
因此,在这种情况下,它不像Stream::split
您的问题所建议的那样,因为根据您的观察tokio::net::TcpStream
,它不是Stream
.
推荐阅读
- docker - docker selenium 独立 chrome 或 firefox 问题,org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话
- keycloak - Keycloak 和 Vault 与客户端角色的集成
- ios - IOS 13 不使用 FirebasePushNotificationPlugin 播放通知声音
- vue.js - 带有 v-model 的自定义开关组件不起作用
- ruby-on-rails - ActiveRecordy has_many 通过我需要找到至少一个孩子满足条件的所有父母
- angular - docker-compose:尝试使用 oauth 身份验证安装 MDBoostrap Pro 时出错
- reactjs - 使用 Jest 测试处理 webpack 加载器语法:感叹号 raw-loader
- amazon-web-services - k8s服务开放端口后大量连接日志
- ssl - 在 Tomcat 5.5 Http11Protocol 中启用 TLS 1.2
- asp.net - 如何在 asp.net mvc core 中显示自定义的 404 错误页面