mirror of
https://github.com/fafhrd91/actix-net
synced 2025-08-22 09:45:06 +02:00
make service Request type generic
This commit is contained in:
@@ -13,9 +13,9 @@ pub struct MapInitErr<A, F, E, C> {
|
||||
|
||||
impl<A, F, E, C> MapInitErr<A, F, E, C> {
|
||||
/// Create new `MapInitErr` combinator
|
||||
pub fn new(a: A, f: F) -> Self
|
||||
pub fn new<R>(a: A, f: F) -> Self
|
||||
where
|
||||
A: NewService<C>,
|
||||
A: NewService<R, C>,
|
||||
F: Fn(A::InitError) -> E,
|
||||
{
|
||||
Self {
|
||||
@@ -40,46 +40,38 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, F, E, C> NewService<C> for MapInitErr<A, F, E, C>
|
||||
impl<A, F, E, R, C> NewService<R, C> for MapInitErr<A, F, E, C>
|
||||
where
|
||||
A: NewService<C>,
|
||||
A: NewService<R, C>,
|
||||
F: Fn(A::InitError) -> E + Clone,
|
||||
{
|
||||
type Request = A::Request;
|
||||
type Response = A::Response;
|
||||
type Error = A::Error;
|
||||
type Service = A::Service;
|
||||
|
||||
type InitError = E;
|
||||
type Future = MapInitErrFuture<A, F, E, C>;
|
||||
type Future = MapInitErrFuture<A, F, E, R, C>;
|
||||
|
||||
fn new_service(&self, cfg: &C) -> Self::Future {
|
||||
MapInitErrFuture::new(self.a.new_service(cfg), self.f.clone())
|
||||
MapInitErrFuture {
|
||||
fut: self.a.new_service(cfg),
|
||||
f: self.f.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MapInitErrFuture<A, F, E, C>
|
||||
pub struct MapInitErrFuture<A, F, E, R, C>
|
||||
where
|
||||
A: NewService<C>,
|
||||
A: NewService<R, C>,
|
||||
F: Fn(A::InitError) -> E,
|
||||
{
|
||||
f: F,
|
||||
fut: A::Future,
|
||||
}
|
||||
|
||||
impl<A, F, E, C> MapInitErrFuture<A, F, E, C>
|
||||
impl<A, F, E, R, C> Future for MapInitErrFuture<A, F, E, R, C>
|
||||
where
|
||||
A: NewService<C>,
|
||||
F: Fn(A::InitError) -> E,
|
||||
{
|
||||
fn new(fut: A::Future, f: F) -> Self {
|
||||
MapInitErrFuture { f, fut }
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, F, E, C> Future for MapInitErrFuture<A, F, E, C>
|
||||
where
|
||||
A: NewService<C>,
|
||||
A: NewService<R, C>,
|
||||
F: Fn(A::InitError) -> E,
|
||||
{
|
||||
type Item = A::Service;
|
||||
|
Reference in New Issue
Block a user