use futures::Future;
mod boxed_result;
mod invert;
mod fuse;
mod pinned;
pub use futures::{Async, Poll};
pub use self::boxed_result::BoxedResult;
pub use self::invert::InvertStatus;
pub use self::fuse::Fuse;
pub use self::pinned::Pinned;
pub trait EnvFuture<E: ?Sized> {
type Item;
type Error;
fn poll(&mut self, env: &mut E) -> Poll<Self::Item, Self::Error>;
fn cancel(&mut self, env: &mut E);
fn pin_env(self, env: E) -> Pinned<E, Self> where E: Sized, Self: Sized {
pinned::new(self, env)
}
fn fuse(self) -> Fuse<Self> where Self: Sized {
fuse::new(self)
}
fn boxed_result<'a>(self) -> BoxedResult<'a, Self>
where Self: Sized,
Self::Item: 'a + Future,
{
boxed_result::new(self)
}
}
impl<'a, T: ?Sized, E: ?Sized> EnvFuture<E> for &'a mut T where T: EnvFuture<E> {
type Item = T::Item;
type Error = T::Error;
fn poll(&mut self, env: &mut E) -> Poll<Self::Item, Self::Error> {
(**self).poll(env)
}
fn cancel(&mut self, env: &mut E) {
(**self).cancel(env)
}
}
impl<T: ?Sized, E: ?Sized> EnvFuture<E> for Box<T> where T: EnvFuture<E> {
type Item = T::Item;
type Error = T::Error;
fn poll(&mut self, env: &mut E) -> Poll<Self::Item, Self::Error> {
(**self).poll(env)
}
fn cancel(&mut self, env: &mut E) {
(**self).cancel(env)
}
}