crypto_util/
future.rs

1// Future utilities.
2
3use futures::Future;
4
5/// Boxed future.
6pub type BoxFuture<Item, Error> = Box<Future<Item = Item, Error = Error>>;
7
8/// Future utility extensions.
9pub trait FutureExt: Future + Sized {
10    /// Boxes a future.
11    fn into_box(self) -> Box<Future<Item = Self::Item, Error = Self::Error>>;
12}
13
14impl<T: Future + 'static> FutureExt for T {
15    fn into_box(self) -> Box<Future<Item = Self::Item, Error = Self::Error>> {
16        Box::new(self)
17    }
18}
19
20pub mod boxfuture {
21    use futures::future;
22    use futures::future::FutureResult;
23
24    /// Creates a boxed future result.
25    pub fn ok<T, E>(t: T) -> Box<FutureResult<T, E>> {
26        Box::new(future::ok(t))
27    }
28}