I am using rustls
, and want to read TlsStream
to a buffer likewise we read TcpStream
. Here is what I am doing:
let acceptor = TlsAcceptor::from(Arc::new(config));
let fut = async {
let mut listener = TcpListener::bind(&addr).await?;
loop {
let (stream, peer_addr) = listener.accept().await?;
let acceptor = acceptor.clone();
let fut = async move {
let mut stream = acceptor.accept(stream).await?;
//// CURRENTLY THIS .read() is throwing error in compiler
println!("Stream: {:?}", stream.read(&mut [0; 1024]));
Ok(()) as io::Result<()>
};
handle.spawn(fut.unwrap_or_else(|err| eprintln!("{:?}", err)));
}
};
It throws error
'error[E0599]: no method named read
found for struct tokio_rustls::server::TlsStream<tokio::net::tcp::stream::TcpStream>
in the current scope'
I am looking to read from TlsStream
generated using tokio-rustls
to buffer.