1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-08-20 13:25:37 +02:00

use concrete types

This commit is contained in:
Nikolay Kim
2019-11-18 14:30:04 +06:00
parent c1cdc9908a
commit 7404d82a9b
25 changed files with 568 additions and 746 deletions

View File

@@ -3,12 +3,10 @@ use std::marker::PhantomData;
use std::pin::Pin;
use std::task::{Context, Poll};
use pin_project::pin_project;
use super::ServiceFactory;
/// `MapInitErr` service combinator
pub(crate) struct MapInitErr<A, F, E> {
pub struct MapInitErr<A, F, E> {
a: A,
f: F,
e: PhantomData<E>,
@@ -46,7 +44,8 @@ where
impl<A, F, E> ServiceFactory for MapInitErr<A, F, E>
where
A: ServiceFactory,
F: Fn(A::InitError) -> E + Clone,
A::Future: Unpin,
F: Fn(A::InitError) -> E + Unpin + Clone,
{
type Request = A::Request;
type Response = A::Response;
@@ -61,14 +60,13 @@ where
MapInitErrFuture::new(self.a.new_service(cfg), self.f.clone())
}
}
#[pin_project]
pub(crate) struct MapInitErrFuture<A, F, E>
pub struct MapInitErrFuture<A, F, E>
where
A: ServiceFactory,
F: Fn(A::InitError) -> E,
{
f: F,
#[pin]
fut: A::Future,
}
@@ -85,12 +83,13 @@ where
impl<A, F, E> Future for MapInitErrFuture<A, F, E>
where
A: ServiceFactory,
F: Fn(A::InitError) -> E,
A::Future: Unpin,
F: Fn(A::InitError) -> E + Unpin,
{
type Output = Result<A::Service, E>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();
this.fut.poll(cx).map_err(this.f)
let this = self.get_mut();
Pin::new(&mut this.fut).poll(cx).map_err(&this.f)
}
}