mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-24 00:01:11 +01:00
add IntoNewService for FnNewService
This commit is contained in:
parent
d2bd9134aa
commit
6b4010892d
@ -142,6 +142,16 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, Req, Out, Cfg> IntoNewService<FnNewService<F, Req, Out, Cfg>, Cfg> for F
|
||||
where
|
||||
F: Fn(Req) -> Out + Clone,
|
||||
Out: IntoFuture,
|
||||
{
|
||||
fn into_new_service(self) -> FnNewService<F, Req, Out, Cfg> {
|
||||
FnNewService::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Converter for `Fn() -> Future<Service>` fn
|
||||
pub struct FnNewServiceNoConfig<F, R, S, E>
|
||||
where
|
||||
@ -256,13 +266,13 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, C, R, S, E> IntoNewService<FnNewServiceConfig<F, C, R, S, E>, C> for F
|
||||
where
|
||||
F: Fn(&C) -> R,
|
||||
R: IntoFuture<Item = S, Error = E>,
|
||||
S: Service,
|
||||
{
|
||||
fn into_new_service(self) -> FnNewServiceConfig<F, C, R, S, E> {
|
||||
FnNewServiceConfig::new(self)
|
||||
}
|
||||
}
|
||||
// impl<F, C, R, S, E> IntoNewService<FnNewServiceConfig<F, C, R, S, E>, C> for F
|
||||
// where
|
||||
// F: Fn(&C) -> R,
|
||||
// R: IntoFuture<Item = S, Error = E>,
|
||||
// S: Service,
|
||||
// {
|
||||
// fn into_new_service(self) -> FnNewServiceConfig<F, C, R, S, E> {
|
||||
// FnNewServiceConfig::new(self)
|
||||
// }
|
||||
// }
|
||||
|
@ -229,7 +229,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_new_service() {
|
||||
let blank = |_: &()| Ok::<_, ()>(Srv);
|
||||
let blank = || Ok::<_, ()>(Srv);
|
||||
let new_srv = blank.into_new_service().map_err(|_| "error");
|
||||
if let Async::Ready(mut srv) = new_srv.new_service(&()).poll().unwrap() {
|
||||
let res = srv.call(()).poll();
|
||||
|
Loading…
Reference in New Issue
Block a user