pub trait AsyncWait<I, E> {
// Required method
fn async_wait(self) -> Result<I, E>;
}
Expand description
AsyncWait implements a .wait()
equivalent that works from any contex.
This is required because at some point in the past .wait()
stopped doing this,
and thus calling it in a polling context causes everything to lock up.
see: https://github.com/tokio-rs/tokio-core/issues/182 and related issues.
// This will block forever if run in the main thread context
let _client = TcpConnection::<JsonCodec<Request, Response>>::new(&addr, JsonCodec::new()).wait().unwrap();
// This will work in the expected manner and return once connection has completed
let _client = TcpConnection::<JsonCodec<Request, Response>>::new(&addr, JsonCodec::new()).async_wait().unwrap();