1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use crate::Error; use pin_project::pin_project; use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; #[pin_project] pub struct ResponseFuture<F> { #[pin] inner: F, } impl<F> ResponseFuture<F> { pub(crate) fn new(inner: F) -> Self { ResponseFuture { inner } } } impl<F, T, E> Future for ResponseFuture<F> where F: Future<Output = Result<T, E>>, E: Into<Error>, { type Output = Result<T, Error>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { self.project().inner.poll(cx).map_err(Into::into) } }