mirror of
https://github.com/fafhrd91/actix-net
synced 2024-12-12 15:00:22 +01:00
move into fn service impl
This commit is contained in:
parent
0390ff37d3
commit
41eddae266
@ -6,7 +6,7 @@ use futures::{
|
|||||||
};
|
};
|
||||||
use tower_service::{NewService, Service};
|
use tower_service::{NewService, Service};
|
||||||
|
|
||||||
use super::IntoNewService;
|
use super::{IntoNewService, IntoService};
|
||||||
|
|
||||||
pub struct FnService<F, Req, Resp, E, Fut>
|
pub struct FnService<F, Req, Resp, E, Fut>
|
||||||
where
|
where
|
||||||
@ -68,6 +68,16 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<F, Req, Resp, Err, Fut> IntoService<FnService<F, Req, Resp, Err, Fut>> for F
|
||||||
|
where
|
||||||
|
F: Fn(Req) -> Fut + 'static,
|
||||||
|
Fut: IntoFuture<Item = Resp, Error = Err>,
|
||||||
|
{
|
||||||
|
fn into_service(self) -> FnService<F, Req, Resp, Err, Fut> {
|
||||||
|
FnService::new(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct FnNewService<F, Req, Resp, Err, IErr, Fut>
|
pub struct FnNewService<F, Req, Resp, Err, IErr, Fut>
|
||||||
where
|
where
|
||||||
F: Fn(Req) -> Fut,
|
F: Fn(Req) -> Fut,
|
||||||
|
@ -103,15 +103,15 @@ pub trait NewServiceExt: NewService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Service> ServiceExt for T {}
|
impl<T: ?Sized> ServiceExt for T where T: Service {}
|
||||||
impl<T: NewService> NewServiceExt for T {}
|
impl<T: ?Sized> NewServiceExt for T where T: NewService {}
|
||||||
|
|
||||||
/// Trait for types that can be converted to a Service
|
/// Trait for types that can be converted to a `Service`
|
||||||
pub trait IntoService<T>
|
pub trait IntoService<T>
|
||||||
where
|
where
|
||||||
T: Service,
|
T: Service,
|
||||||
{
|
{
|
||||||
/// Create service
|
/// Convert to a `Service`
|
||||||
fn into_service(self) -> T;
|
fn into_service(self) -> T;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ pub trait IntoNewService<T>
|
|||||||
where
|
where
|
||||||
T: NewService,
|
T: NewService,
|
||||||
{
|
{
|
||||||
/// Create service
|
/// Convert to an `NewService`
|
||||||
fn into_new_service(self) -> T;
|
fn into_new_service(self) -> T;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,13 +141,3 @@ where
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, Req, Resp, Err, Fut> IntoService<FnService<F, Req, Resp, Err, Fut>> for F
|
|
||||||
where
|
|
||||||
F: Fn(Req) -> Fut + 'static,
|
|
||||||
Fut: IntoFuture<Item = Resp, Error = Err>,
|
|
||||||
{
|
|
||||||
fn into_service(self) -> FnService<F, Req, Resp, Err, Fut> {
|
|
||||||
FnService::new(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user