add changelog entry

This commit is contained in:
Rob Ede 2020-12-27 02:15:25 +00:00
parent f5808c6c40
commit 7de866dab3
No known key found for this signature in database
GPG Key ID: C2A3B36E841A91E6
10 changed files with 192 additions and 180 deletions

View File

@ -1,8 +1,14 @@
# Changes
## Unreleased - 2020-xx-xx
* `Service`, other traits, and many type signatures now take the the request type as a type
parameter instead of an associated type. [#232]
* Upgrade `pin-project` to `1.0`.
[#232]: https://github.com/actix/actix-net/pull/232
## 1.0.6 - 2020-08-09
### Fixed

View File

@ -12,12 +12,12 @@ use super::{IntoService, IntoServiceFactory, Service, ServiceFactory};
/// Apply transform function to a service.
///
/// The In and Out type params refer to the request and response types for the wrapped service.
pub fn apply_fn<U, S, F, Fut, Req, In, Res, Err>(
service: U,
pub fn apply_fn<I, S, F, Fut, Req, In, Res, Err>(
service: I,
wrap_fn: F,
) -> Apply<S, F, Req, In, Res, Err>
where
U: IntoService<S, In>,
I: IntoService<S, In>,
S: Service<In, Error = Err>,
F: FnMut(Req, &mut S) -> Fut,
Fut: Future<Output = Result<Res, Err>>,
@ -28,12 +28,12 @@ where
/// Service factory that produces `apply_fn` service.
///
/// The In and Out type params refer to the request and response types for the wrapped service.
pub fn apply_fn_factory<U, SF, F, Fut, Req, In, Res, Err>(
service: U,
pub fn apply_fn_factory<I, SF, F, Fut, Req, In, Res, Err>(
service: I,
f: F,
) -> ApplyFactory<SF, F, Req, In, Res, Err>
where
U: IntoServiceFactory<SF, In>,
I: IntoServiceFactory<SF, In>,
SF: ServiceFactory<In, Error = Err>,
F: FnMut(Req, &mut SF::Service) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>,

View File

@ -7,150 +7,152 @@ use std::task::{Context, Poll};
use crate::{Service, ServiceFactory};
/// Convert `Fn(Config, &mut Service1) -> Future<Service2>` fn to a service factory
pub fn apply_cfg<F, C, T, Req, R, S, E>(
srv: T,
/// Convert `Fn(Config, &mut Service1) -> Future<Service2>` fn to a service factory.
pub fn apply_cfg<S1, Req, F, Cfg, Fut, S2, Err>(
srv: S1,
f: F,
) -> impl ServiceFactory<
Req,
Config = C,
Response = S::Response,
Error = S::Error,
Service = S,
InitError = E,
Future = R,
Config = Cfg,
Response = S2::Response,
Error = S2::Error,
Service = S2,
InitError = Err,
Future = Fut,
> + Clone
where
F: FnMut(C, &mut T) -> R,
T: Service<Req>,
R: Future<Output = Result<S, E>>,
S: Service<Req>,
S1: Service<Req>,
F: FnMut(Cfg, &mut S1) -> Fut,
Fut: Future<Output = Result<S2, Err>>,
S2: Service<Req>,
{
ApplyConfigService {
srv: Rc::new(RefCell::new((srv, f))),
_t: PhantomData,
_phantom: PhantomData,
}
}
/// Convert `Fn(Config, &mut Service1) -> Future<Service2>` fn to a service factory
/// Convert `Fn(Config, &mut ServiceFactory1) -> Future<ServiceFactory2>` fn to a service factory.
///
/// Service1 get constructed from `T` factory.
pub fn apply_cfg_factory<F, C, Req, T, R, S>(
factory: T,
pub fn apply_cfg_factory<SF, Req, F, Cfg, Fut, S>(
factory: SF,
f: F,
) -> impl ServiceFactory<
Req,
Config = C,
Config = Cfg,
Response = S::Response,
Error = S::Error,
Service = S,
InitError = T::InitError,
InitError = SF::InitError,
> + Clone
where
F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Req, Config = ()>,
T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>,
SF: ServiceFactory<Req, Config = ()>,
F: FnMut(Cfg, &mut SF::Service) -> Fut,
SF::InitError: From<SF::Error>,
Fut: Future<Output = Result<S, SF::InitError>>,
S: Service<Req>,
{
ApplyConfigServiceFactory {
srv: Rc::new(RefCell::new((factory, f))),
_t: PhantomData,
_phantom: PhantomData,
}
}
/// Convert `Fn(Config, &mut Server) -> Future<Service>` fn to NewService\
struct ApplyConfigService<F, C, Req, T, R, S, E>
struct ApplyConfigService<S1, Req, F, Cfg, Fut, S2, Err>
where
F: FnMut(C, &mut T) -> R,
T: Service<Req>,
R: Future<Output = Result<S, E>>,
S: Service<Req>,
S1: Service<Req>,
F: FnMut(Cfg, &mut S1) -> Fut,
Fut: Future<Output = Result<S2, Err>>,
S2: Service<Req>,
{
srv: Rc<RefCell<(T, F)>>,
_t: PhantomData<(C, Req, R, S)>,
srv: Rc<RefCell<(S1, F)>>,
_phantom: PhantomData<(Cfg, Req, Fut, S2)>,
}
impl<F, C, Req, T, R, S, E> Clone for ApplyConfigService<F, C, Req, T, R, S, E>
impl<S1, Req, F, Cfg, Fut, S2, Err> Clone for ApplyConfigService<S1, Req, F, Cfg, Fut, S2, Err>
where
F: FnMut(C, &mut T) -> R,
T: Service<Req>,
R: Future<Output = Result<S, E>>,
S: Service<Req>,
S1: Service<Req>,
F: FnMut(Cfg, &mut S1) -> Fut,
Fut: Future<Output = Result<S2, Err>>,
S2: Service<Req>,
{
fn clone(&self) -> Self {
ApplyConfigService {
srv: self.srv.clone(),
_t: PhantomData,
_phantom: PhantomData,
}
}
}
impl<F, C, Req, T, R, S, E> ServiceFactory<Req> for ApplyConfigService<F, C, Req, T, R, S, E>
impl<S1, Req, F, Cfg, Fut, S2, Err> ServiceFactory<Req>
for ApplyConfigService<S1, Req, F, Cfg, Fut, S2, Err>
where
F: FnMut(C, &mut T) -> R,
T: Service<Req>,
R: Future<Output = Result<S, E>>,
S: Service<Req>,
S1: Service<Req>,
F: FnMut(Cfg, &mut S1) -> Fut,
Fut: Future<Output = Result<S2, Err>>,
S2: Service<Req>,
{
type Config = C;
type Response = S::Response;
type Error = S::Error;
type Service = S;
type Config = Cfg;
type Response = S2::Response;
type Error = S2::Error;
type Service = S2;
type InitError = E;
type Future = R;
type InitError = Err;
type Future = Fut;
fn new_service(&self, cfg: C) -> Self::Future {
fn new_service(&self, cfg: Cfg) -> Self::Future {
let (t, f) = &mut *self.srv.borrow_mut();
f(cfg, t)
}
}
/// Convert `Fn(&Config) -> Future<Service>` fn to NewService
struct ApplyConfigServiceFactory<F, C, Req, T, R, S>
struct ApplyConfigServiceFactory<SF, Req, F, Cfg, Fut, S>
where
F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Req, Config = ()>,
R: Future<Output = Result<S, T::InitError>>,
SF: ServiceFactory<Req, Config = ()>,
F: FnMut(Cfg, &mut SF::Service) -> Fut,
Fut: Future<Output = Result<S, SF::InitError>>,
S: Service<Req>,
{
srv: Rc<RefCell<(T, F)>>,
_t: PhantomData<(C, Req, R, S)>,
srv: Rc<RefCell<(SF, F)>>,
_phantom: PhantomData<(Cfg, Req, Fut, S)>,
}
impl<F, C, Req, T, R, S> Clone for ApplyConfigServiceFactory<F, C, Req, T, R, S>
impl<SF, Req, F, Cfg, Fut, S> Clone for ApplyConfigServiceFactory<SF, Req, F, Cfg, Fut, S>
where
F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Req, Config = ()>,
R: Future<Output = Result<S, T::InitError>>,
SF: ServiceFactory<Req, Config = ()>,
F: FnMut(Cfg, &mut SF::Service) -> Fut,
Fut: Future<Output = Result<S, SF::InitError>>,
S: Service<Req>,
{
fn clone(&self) -> Self {
Self {
srv: self.srv.clone(),
_t: PhantomData,
_phantom: PhantomData,
}
}
}
impl<F, C, Req, T, R, S> ServiceFactory<Req> for ApplyConfigServiceFactory<F, C, Req, T, R, S>
impl<SF, Req, F, Cfg, Fut, S> ServiceFactory<Req>
for ApplyConfigServiceFactory<SF, Req, F, Cfg, Fut, S>
where
F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Req, Config = ()>,
T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>,
SF: ServiceFactory<Req, Config = ()>,
SF::InitError: From<SF::Error>,
F: FnMut(Cfg, &mut SF::Service) -> Fut,
Fut: Future<Output = Result<S, SF::InitError>>,
S: Service<Req>,
{
type Config = C;
type Config = Cfg;
type Response = S::Response;
type Error = S::Error;
type Service = S;
type InitError = T::InitError;
type Future = ApplyConfigServiceFactoryResponse<F, C, Req, T, R, S>;
type InitError = SF::InitError;
type Future = ApplyConfigServiceFactoryResponse<SF, Req, F, Cfg, Fut, S>;
fn new_service(&self, cfg: C) -> Self::Future {
fn new_service(&self, cfg: Cfg) -> Self::Future {
ApplyConfigServiceFactoryResponse {
cfg: Some(cfg),
store: self.srv.clone(),
@ -160,42 +162,43 @@ where
}
#[pin_project::pin_project]
struct ApplyConfigServiceFactoryResponse<F, C, Req, T, R, S>
struct ApplyConfigServiceFactoryResponse<SF, Req, F, Cfg, Fut, S>
where
F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Req, Config = ()>,
T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>,
SF: ServiceFactory<Req, Config = ()>,
SF::InitError: From<SF::Error>,
F: FnMut(Cfg, &mut SF::Service) -> Fut,
Fut: Future<Output = Result<S, SF::InitError>>,
S: Service<Req>,
{
cfg: Option<C>,
store: Rc<RefCell<(T, F)>>,
cfg: Option<Cfg>,
store: Rc<RefCell<(SF, F)>>,
#[pin]
state: State<T, R, S, Req>,
state: State<SF, Fut, S, Req>,
}
#[pin_project::pin_project(project = StateProj)]
enum State<T, R, S, Req>
enum State<SF, Fut, S, Req>
where
T: ServiceFactory<Req, Config = ()>,
T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>,
SF: ServiceFactory<Req, Config = ()>,
SF::InitError: From<SF::Error>,
Fut: Future<Output = Result<S, SF::InitError>>,
S: Service<Req>,
{
A(#[pin] T::Future),
B(T::Service),
C(#[pin] R),
A(#[pin] SF::Future),
B(SF::Service),
C(#[pin] Fut),
}
impl<F, C, Req, T, R, S> Future for ApplyConfigServiceFactoryResponse<F, C, Req, T, R, S>
impl<SF, Req, F, Cfg, Fut, S> Future
for ApplyConfigServiceFactoryResponse<SF, Req, F, Cfg, Fut, S>
where
F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Req, Config = ()>,
T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>,
SF: ServiceFactory<Req, Config = ()>,
SF::InitError: From<SF::Error>,
F: FnMut(Cfg, &mut SF::Service) -> Fut,
Fut: Future<Output = Result<S, SF::InitError>>,
S: Service<Req>,
{
type Output = Result<S, T::InitError>;
type Output = Result<S, SF::InitError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.as_mut().project();

View File

@ -14,17 +14,17 @@ pub type BoxService<Req, Res, Err> =
pub struct BoxServiceFactory<Cfg, Req, Res, Err, InitErr>(Inner<Cfg, Req, Res, Err, InitErr>);
/// Create boxed service factory
pub fn factory<T, Req>(
factory: T,
) -> BoxServiceFactory<T::Config, Req, T::Response, T::Error, T::InitError>
pub fn factory<SF, Req>(
factory: SF,
) -> BoxServiceFactory<SF::Config, Req, SF::Response, SF::Error, SF::InitError>
where
T: ServiceFactory<Req> + 'static,
SF: ServiceFactory<Req> + 'static,
Req: 'static,
T::Response: 'static,
T::Service: 'static,
T::Future: 'static,
T::Error: 'static,
T::InitError: 'static,
SF::Response: 'static,
SF::Service: 'static,
SF::Future: 'static,
SF::Error: 'static,
SF::InitError: 'static,
{
BoxServiceFactory(Box::new(FactoryWrapper {
factory,
@ -75,33 +75,33 @@ where
}
}
struct FactoryWrapper<C, T, Req>
struct FactoryWrapper<SF, Req, C>
where
T: ServiceFactory<Req>,
SF: ServiceFactory<Req>,
{
factory: T,
factory: SF,
_t: PhantomData<(C, Req)>,
}
impl<C, T, Req, Res, Err, InitErr> ServiceFactory<Req> for FactoryWrapper<C, T, Req>
impl<SF, Req, Cfg, Res, Err, InitErr> ServiceFactory<Req> for FactoryWrapper<SF, Req, Cfg>
where
Req: 'static,
Res: 'static,
Err: 'static,
InitErr: 'static,
T: ServiceFactory<Req, Config = C, Response = Res, Error = Err, InitError = InitErr>,
T::Future: 'static,
T::Service: 'static,
<T::Service as Service<Req>>::Future: 'static,
SF: ServiceFactory<Req, Config = Cfg, Response = Res, Error = Err, InitError = InitErr>,
SF::Future: 'static,
SF::Service: 'static,
<SF::Service as Service<Req>>::Future: 'static,
{
type Response = Res;
type Error = Err;
type InitError = InitErr;
type Config = C;
type Config = Cfg;
type Service = BoxService<Req, Res, Err>;
type Future = BoxFuture<Self::Service, Self::InitError>;
fn new_service(&self, cfg: C) -> Self::Future {
fn new_service(&self, cfg: Cfg) -> Self::Future {
Box::pin(
self.factory
.new_service(cfg)
@ -123,10 +123,10 @@ where
}
}
impl<T, Req, Res, Err> Service<Req> for ServiceWrapper<T, Req>
impl<S, Req, Res, Err> Service<Req> for ServiceWrapper<S, Req>
where
T: Service<Req, Response = Res, Error = Err>,
T::Future: 'static,
S: Service<Req, Response = Res, Error = Err>,
S::Future: 'static,
{
type Response = Res;
type Error = Err;

View File

@ -338,10 +338,10 @@ where
}
}
/// Convert object of type `T` to a service `S`
pub fn into_service<U, S, Req>(tp: U) -> S
/// Convert object of type `U` to a service `S`
pub fn into_service<I, S, Req>(tp: I) -> S
where
U: IntoService<S, Req>,
I: IntoService<S, Req>,
S: Service<Req>,
{
tp.into_service()

View File

@ -6,9 +6,9 @@ use super::{IntoServiceFactory, ServiceFactory};
///
/// Note that this function consumes the receiving service factory and returns
/// a wrapped version of it.
pub fn map_config<U, SF, S, Req, F, Cfg>(factory: U, f: F) -> MapConfig<SF, Req, F, Cfg>
pub fn map_config<I, SF, S, Req, F, Cfg>(factory: I, f: F) -> MapConfig<SF, Req, F, Cfg>
where
U: IntoServiceFactory<SF, Req>,
I: IntoServiceFactory<SF, Req>,
SF: ServiceFactory<Req>,
F: Fn(Cfg) -> SF::Config,
{
@ -16,9 +16,9 @@ where
}
/// Replace config with unit.
pub fn unit_config<U, SF, Cfg, Req>(factory: U) -> UnitConfig<SF, Cfg, Req>
pub fn unit_config<I, SF, Cfg, Req>(factory: I) -> UnitConfig<SF, Cfg, Req>
where
U: IntoServiceFactory<SF, Req>,
I: IntoServiceFactory<SF, Req>,
SF: ServiceFactory<Req, Config = ()>,
{
UnitConfig::new(factory.into_factory())

View File

@ -10,9 +10,9 @@ use crate::then::{ThenService, ThenServiceFactory};
use crate::{IntoService, IntoServiceFactory, Service, ServiceFactory};
/// Construct new pipeline with one service in pipeline chain.
pub fn pipeline<U, S, Req>(service: U) -> Pipeline<S, Req>
pub fn pipeline<I, S, Req>(service: I) -> Pipeline<S, Req>
where
U: IntoService<S, Req>,
I: IntoService<S, Req>,
S: Service<Req>,
{
Pipeline {
@ -22,9 +22,9 @@ where
}
/// Construct new pipeline factory with one service factory.
pub fn pipeline_factory<U, SF, Req>(factory: U) -> PipelineFactory<SF, Req>
pub fn pipeline_factory<I, SF, Req>(factory: I) -> PipelineFactory<SF, Req>
where
U: IntoServiceFactory<SF, Req>,
I: IntoServiceFactory<SF, Req>,
SF: ServiceFactory<Req>,
{
PipelineFactory {
@ -52,14 +52,14 @@ where
///
/// Note that this function consumes the receiving service and returns a
/// wrapped version of it.
pub fn and_then<F, U>(
pub fn and_then<I, S1>(
self,
service: F,
) -> Pipeline<impl Service<Req, Response = U::Response, Error = S::Error> + Clone, Req>
service: I,
) -> Pipeline<impl Service<Req, Response = S1::Response, Error = S::Error> + Clone, Req>
where
Self: Sized,
F: IntoService<U, S::Response>,
U: Service<S::Response, Error = S::Error>,
I: IntoService<S1, S::Response>,
S1: Service<S::Response, Error = S::Error>,
{
Pipeline {
service: AndThenService::new(self.service, service.into_service()),
@ -70,14 +70,14 @@ where
/// Apply function to specified service and use it as a next service in chain.
///
/// Short version of `pipeline_factory(...).and_then(apply_fn(...))`
pub fn and_then_apply_fn<U, S1, F, Fut, In, Res, Err>(
pub fn and_then_apply_fn<I, S1, F, Fut, In, Res, Err>(
self,
service: U,
service: I,
wrap_fn: F,
) -> Pipeline<impl Service<Req, Response = Res, Error = Err> + Clone, Req>
where
Self: Sized,
U: IntoService<S1, In>,
I: IntoService<S1, In>,
S1: Service<In>,
F: FnMut(S::Response, &mut S1) -> Fut,
Fut: Future<Output = Result<Res, Err>>,
@ -94,14 +94,14 @@ where
///
/// Note that this function consumes the receiving pipeline and returns a
/// wrapped version of it.
pub fn then<F, U>(
pub fn then<F, S1>(
self,
service: F,
) -> Pipeline<impl Service<Req, Response = U::Response, Error = S::Error> + Clone, Req>
) -> Pipeline<impl Service<Req, Response = S1::Response, Error = S::Error> + Clone, Req>
where
Self: Sized,
F: IntoService<U, Result<S::Response, S::Error>>,
U: Service<Result<S::Response, S::Error>, Error = S::Error>,
F: IntoService<S1, Result<S::Response, S::Error>>,
S1: Service<Result<S::Response, S::Error>, Error = S::Error>,
{
Pipeline {
service: ThenService::new(self.service, service.into_service()),
@ -161,13 +161,13 @@ where
}
}
impl<T: Service<Req>, Req> Service<Req> for Pipeline<T, Req> {
type Response = T::Response;
type Error = T::Error;
type Future = T::Future;
impl<S: Service<Req>, Req> Service<Req> for Pipeline<S, Req> {
type Response = S::Response;
type Error = S::Error;
type Future = S::Future;
#[inline]
fn poll_ready(&mut self, ctx: &mut Context<'_>) -> Poll<Result<(), T::Error>> {
fn poll_ready(&mut self, ctx: &mut Context<'_>) -> Poll<Result<(), S::Error>> {
self.service.poll_ready(ctx)
}
@ -188,25 +188,25 @@ where
SF: ServiceFactory<Req>,
{
/// Call another service after call to this one has resolved successfully.
pub fn and_then<F, U>(
pub fn and_then<I, SF1>(
self,
factory: F,
factory: I,
) -> PipelineFactory<
impl ServiceFactory<
Req,
Response = U::Response,
Response = SF1::Response,
Error = SF::Error,
Config = SF::Config,
InitError = SF::InitError,
Service = impl Service<Req, Response = U::Response, Error = SF::Error> + Clone,
Service = impl Service<Req, Response = SF1::Response, Error = SF::Error> + Clone,
> + Clone,
Req,
>
where
Self: Sized,
SF::Config: Clone,
F: IntoServiceFactory<U, SF::Response>,
U: ServiceFactory<
I: IntoServiceFactory<SF1, SF::Response>,
SF1: ServiceFactory<
SF::Response,
Config = SF::Config,
Error = SF::Error,
@ -222,9 +222,9 @@ where
/// Apply function to specified service and use it as a next service in chain.
///
/// Short version of `pipeline_factory(...).and_then(apply_fn_factory(...))`
pub fn and_then_apply_fn<U, SF1, Fut, F, In, Res, Err>(
pub fn and_then_apply_fn<I, SF1, Fut, F, In, Res, Err>(
self,
factory: U,
factory: I,
wrap_fn: F,
) -> PipelineFactory<
impl ServiceFactory<
@ -240,7 +240,7 @@ where
where
Self: Sized,
SF::Config: Clone,
U: IntoServiceFactory<SF1, In>,
I: IntoServiceFactory<SF1, In>,
SF1: ServiceFactory<In, Config = SF::Config, InitError = SF::InitError>,
F: FnMut(SF::Response, &mut SF1::Service) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>,
@ -258,25 +258,25 @@ where
///
/// Note that this function consumes the receiving pipeline and returns a
/// wrapped version of it.
pub fn then<F, U>(
pub fn then<I, SF1>(
self,
factory: F,
factory: I,
) -> PipelineFactory<
impl ServiceFactory<
Req,
Response = U::Response,
Response = SF1::Response,
Error = SF::Error,
Config = SF::Config,
InitError = SF::InitError,
Service = impl Service<Req, Response = U::Response, Error = SF::Error> + Clone,
Service = impl Service<Req, Response = SF1::Response, Error = SF::Error> + Clone,
> + Clone,
Req,
>
where
Self: Sized,
SF::Config: Clone,
F: IntoServiceFactory<U, Result<SF::Response, SF::Error>>,
U: ServiceFactory<
I: IntoServiceFactory<SF1, Result<SF::Response, SF::Error>>,
SF1: ServiceFactory<
Result<SF::Response, SF::Error>,
Config = SF::Config,
Error = SF::Error,
@ -342,16 +342,19 @@ where
}
}
impl<T: ServiceFactory<Req>, Req> ServiceFactory<Req> for PipelineFactory<T, Req> {
type Config = T::Config;
type Response = T::Response;
type Error = T::Error;
type Service = T::Service;
type InitError = T::InitError;
type Future = T::Future;
impl<SF, Req> ServiceFactory<Req> for PipelineFactory<SF, Req>
where
SF: ServiceFactory<Req>,
{
type Config = SF::Config;
type Response = SF::Response;
type Error = SF::Error;
type Service = SF::Service;
type InitError = SF::InitError;
type Future = SF::Future;
#[inline]
fn new_service(&self, cfg: T::Config) -> Self::Future {
fn new_service(&self, cfg: SF::Config) -> Self::Future {
self.factory.new_service(cfg)
}
}

View File

@ -8,11 +8,11 @@ use crate::transform_err::TransformMapInitErr;
use crate::{IntoServiceFactory, Service, ServiceFactory};
/// Apply transform to a service.
pub fn apply<T, S, U, Req>(t: T, factory: U) -> ApplyTransform<T, S, Req>
pub fn apply<T, S, I, Req>(t: T, factory: I) -> ApplyTransform<T, S, Req>
where
I: IntoServiceFactory<S, Req>,
S: ServiceFactory<Req>,
T: Transform<S::Service, Req, InitError = S::InitError>,
U: IntoServiceFactory<S, Req>,
{
ApplyTransform::new(t, factory.into_factory())
}

View File

@ -103,14 +103,14 @@ where
/// |req: &Request| Some(span!(Level::INFO, "request", req.id))
/// );
/// ```
pub fn trace<S, Req, U, F>(
service_factory: U,
pub fn trace<S, Req, I, F>(
service_factory: I,
make_span: F,
) -> ApplyTransform<TracingTransform<S::Service, S, F>, S, Req>
where
I: IntoServiceFactory<S, Req>,
S: ServiceFactory<Req>,
F: Fn(&Req) -> Option<tracing::Span> + Clone,
U: IntoServiceFactory<S, Req>,
{
apply(
TracingTransform::new(make_span),

View File

@ -165,21 +165,21 @@ where
pin_project! {
/// `TimeoutService` response future
#[derive(Debug)]
pub struct TimeoutServiceResponse<T, Req>
pub struct TimeoutServiceResponse<S, Req>
where
T: Service<Req>
S: Service<Req>
{
#[pin]
fut: T::Future,
fut: S::Future,
sleep: Delay,
}
}
impl<T, Req> Future for TimeoutServiceResponse<T, Req>
impl<S, Req> Future for TimeoutServiceResponse<S, Req>
where
T: Service<Req>,
S: Service<Req>,
{
type Output = Result<T::Response, TimeoutError<T::Error>>;
type Output = Result<S::Response, TimeoutError<S::Error>>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();