我正在尝试构建一个处理异步websocket通信的结构体。我正在努力建立连接,作为其中的一部分,我正在使用
tokio_tungstenite::connect::connect_async()
。我想将其返回值作为字段存储在我正在处理的结构中。
我尝试了以下方法:
use tokio_tungstenite::tungstenite::stream::MaybeTlsStream;
use tokio_tungstenite::WebSocketStream;
pub struct WrAsyncSocket {
m_socket_stream: Option<WebSocketStream<MaybeTlsStream<TcpStream>>>,
}
有了这个,我尝试了导入这两个:
tokio::net::tcp::stream::TcpStream
和
tokio::net::TcpStream
但是,在任何实例上,这两种情况都会导致以下错误
TcpStream
:
the trait bound `tokio::net::TcpStream: std::io::Read` is not satisfied
the trait `std::io::Read` is not implemented for `tokio::net::TcpStream`rustcClick for full compiler diagnostic
stream.rs(63, 28): required by a bound in `tokio_tungstenite::tungstenite::stream::MaybeTlsStream`
关于我在这里应该做什么,有什么建议吗?