-1

I'm new to Rust and I love the language more and more. I downloaded crate "native-tls" and it has the TlsStream element which replaces TcpStream but it doesn't have the "set_read_timeout" method. How do I access it by mixing libraries or something similar?

Something like this:


let mut stream = TlsStream::conn... 
TcpStream::stream.set_read_timeout(Duration::millis(5000));

navetix
  • 25
  • 4

1 Answers1

1

Two options:

  1. Set the timeout on the TcpStream before you give it to TlsConnector::connect(), or

  2. Use TlsStream::get_mut() to get a mutable reference to the underlying stream, which you can then invoke set_read_timeout() on:

    stream.get_mut().set_read_timeout(Duration::millis(5000));
    
cdhowie
  • 158,093
  • 24
  • 286
  • 300
  • As we say in our country "¡USTÉ ES UN MOSTRO PARCERO!", which translates that "YOU ARE A GENIUS MY FRIEND!". Its works fine. THANK YOU VERY MUCH! – navetix Apr 18 '22 at 17:25