Trait AsyncWait

Source
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();

Required Methods§

Source

fn async_wait(self) -> Result<I, E>

Implementors§

Source§

impl<F, I, E> AsyncWait<I, E> for F
where F: Future<Item = I, Error = E> + Send + 'static, I: Send + 'static, E: Send + 'static,