mirror of
https://github.com/actix/actix-web.git
synced 2024-12-21 23:56:35 +00:00
move into fn service impl
This commit is contained in:
parent
0390ff37d3
commit
41eddae266
2 changed files with 16 additions and 16 deletions
|
@ -6,7 +6,7 @@ use futures::{
|
|||
};
|
||||
use tower_service::{NewService, Service};
|
||||
|
||||
use super::IntoNewService;
|
||||
use super::{IntoNewService, IntoService};
|
||||
|
||||
pub struct FnService<F, Req, Resp, E, Fut>
|
||||
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>
|
||||
where
|
||||
F: Fn(Req) -> Fut,
|
||||
|
|
|
@ -103,15 +103,15 @@ pub trait NewServiceExt: NewService {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Service> ServiceExt for T {}
|
||||
impl<T: NewService> NewServiceExt for T {}
|
||||
impl<T: ?Sized> ServiceExt for T where T: Service {}
|
||||
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>
|
||||
where
|
||||
T: Service,
|
||||
{
|
||||
/// Create service
|
||||
/// Convert to a `Service`
|
||||
fn into_service(self) -> T;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ pub trait IntoNewService<T>
|
|||
where
|
||||
T: NewService,
|
||||
{
|
||||
/// Create service
|
||||
/// Convert to an `NewService`
|
||||
fn into_new_service(self) -> T;
|
||||
}
|
||||
|
||||
|
@ -141,13 +141,3 @@ where
|
|||
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 a new issue