mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-30 19:54:36 +01:00
add IntoConfigurableNewService
This commit is contained in:
parent
6b4010892d
commit
83a19e9cb3
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||||||
use futures::future::{ok, FutureResult};
|
use futures::future::{ok, FutureResult};
|
||||||
use futures::{Async, IntoFuture, Poll};
|
use futures::{Async, IntoFuture, Poll};
|
||||||
|
|
||||||
use super::{IntoNewService, IntoService, NewService, Service};
|
use super::{IntoConfigurableNewService, IntoNewService, IntoService, NewService, Service};
|
||||||
|
|
||||||
/// Create `NewService` for function that can act as Service
|
/// Create `NewService` for function that can act as Service
|
||||||
pub fn fn_service<F, Req, Out>(f: F) -> FnNewService<F, Req, Out, ()>
|
pub fn fn_service<F, Req, Out>(f: F) -> FnNewService<F, Req, Out, ()>
|
||||||
@ -266,13 +266,13 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl<F, C, R, S, E> IntoNewService<FnNewServiceConfig<F, C, R, S, E>, C> for F
|
impl<F, C, R, S, E> IntoConfigurableNewService<FnNewServiceConfig<F, C, R, S, E>, C> for F
|
||||||
// where
|
where
|
||||||
// F: Fn(&C) -> R,
|
F: Fn(&C) -> R,
|
||||||
// R: IntoFuture<Item = S, Error = E>,
|
R: IntoFuture<Item = S, Error = E>,
|
||||||
// S: Service,
|
S: Service,
|
||||||
// {
|
{
|
||||||
// fn into_new_service(self) -> FnNewServiceConfig<F, C, R, S, E> {
|
fn into_new_service(self) -> FnNewServiceConfig<F, C, R, S, E> {
|
||||||
// FnNewServiceConfig::new(self)
|
FnNewServiceConfig::new(self)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
@ -437,3 +437,21 @@ where
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Trait for types that can be converted to a configurable `NewService`
|
||||||
|
pub trait IntoConfigurableNewService<T, C>
|
||||||
|
where
|
||||||
|
T: NewService<C>,
|
||||||
|
{
|
||||||
|
/// Convert to an `NewService`
|
||||||
|
fn into_new_service(self) -> T;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T, C> IntoConfigurableNewService<T, C> for T
|
||||||
|
where
|
||||||
|
T: NewService<C>,
|
||||||
|
{
|
||||||
|
fn into_new_service(self) -> T {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user