mirror of
https://github.com/actix/actix-web.git
synced 2024-12-22 16:16:40 +00:00
add clone impls for combinator services
This commit is contained in:
parent
8540d81dcf
commit
983223a839
5 changed files with 75 additions and 2 deletions
|
@ -26,6 +26,19 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<A, B> Clone for AndThen<A, B>
|
||||||
|
where
|
||||||
|
A: Service + Clone,
|
||||||
|
B: Service<Request = A::Response, Error = A::Error>,
|
||||||
|
{
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
AndThen {
|
||||||
|
a: self.a.clone(),
|
||||||
|
b: self.b.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<A, B> Service for AndThen<A, B>
|
impl<A, B> Service for AndThen<A, B>
|
||||||
where
|
where
|
||||||
A: Service,
|
A: Service,
|
||||||
|
|
|
@ -27,6 +27,22 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T, F, R, Req> Clone for Apply<T, F, R, Req>
|
||||||
|
where
|
||||||
|
T: Service + Clone,
|
||||||
|
T::Error: Into<<R::Future as Future>::Error>,
|
||||||
|
F: Fn(Req, &mut T) -> R + Clone,
|
||||||
|
R: IntoFuture,
|
||||||
|
{
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Apply {
|
||||||
|
service: self.service.clone(),
|
||||||
|
f: self.f.clone(),
|
||||||
|
r: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T, F, R, Req> Service for Apply<T, F, R, Req>
|
impl<T, F, R, Req> Service for Apply<T, F, R, Req>
|
||||||
where
|
where
|
||||||
T: Service,
|
T: Service,
|
||||||
|
|
|
@ -33,6 +33,23 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<S, F, Req, Resp, Err, Fut> Clone for FnStateService<S, F, Req, Resp, Err, Fut>
|
||||||
|
where
|
||||||
|
S: Clone,
|
||||||
|
F: Fn(&mut S, Req) -> Fut + Clone,
|
||||||
|
Fut: IntoFuture<Item = Resp, Error = Err>,
|
||||||
|
{
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
FnStateService {
|
||||||
|
f: self.f.clone(),
|
||||||
|
state: self.state.clone(),
|
||||||
|
req: marker::PhantomData,
|
||||||
|
resp: marker::PhantomData,
|
||||||
|
err: marker::PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<S, F, Req, Resp, Err, Fut> Service for FnStateService<S, F, Req, Resp, Err, Fut>
|
impl<S, F, Req, Resp, Err, Fut> Service for FnStateService<S, F, Req, Resp, Err, Fut>
|
||||||
where
|
where
|
||||||
F: Fn(&mut S, Req) -> Fut,
|
F: Fn(&mut S, Req) -> Fut,
|
||||||
|
|
|
@ -25,11 +25,24 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<A, F, R> Clone for Map<A, F, R>
|
||||||
|
where
|
||||||
|
A: Service + Clone,
|
||||||
|
F: Fn(A::Response) -> R + Clone,
|
||||||
|
{
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Map {
|
||||||
|
a: self.a.clone(),
|
||||||
|
f: self.f.clone(),
|
||||||
|
r: marker::PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<A, F, R> Service for Map<A, F, R>
|
impl<A, F, R> Service for Map<A, F, R>
|
||||||
where
|
where
|
||||||
A: Service,
|
A: Service,
|
||||||
F: Fn(A::Response) -> R,
|
F: Fn(A::Response) -> R + Clone,
|
||||||
F: Clone,
|
|
||||||
{
|
{
|
||||||
type Request = A::Request;
|
type Request = A::Request;
|
||||||
type Response = R;
|
type Response = R;
|
||||||
|
|
|
@ -25,6 +25,20 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<A, F, E> Clone for MapErr<A, F, E>
|
||||||
|
where
|
||||||
|
A: Service + Clone,
|
||||||
|
F: Fn(A::Error) -> E + Clone,
|
||||||
|
{
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
MapErr {
|
||||||
|
a: self.a.clone(),
|
||||||
|
f: self.f.clone(),
|
||||||
|
e: marker::PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<A, F, E> Service for MapErr<A, F, E>
|
impl<A, F, E> Service for MapErr<A, F, E>
|
||||||
where
|
where
|
||||||
A: Service,
|
A: Service,
|
||||||
|
|
Loading…
Reference in a new issue