mirror of
https://github.com/actix/actix-web.git
synced 2024-12-21 15:46:48 +00:00
add clone impls
This commit is contained in:
parent
ddfe1322a1
commit
f9b9031af2
2 changed files with 28 additions and 1 deletions
|
@ -2,7 +2,7 @@ use std::collections::VecDeque;
|
|||
use std::io;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use futures::{Async, Future, Poll};
|
||||
use futures::{Async, Future, Poll, future::ok};
|
||||
use tokio;
|
||||
use tokio_tcp::{ConnectFuture, TcpStream};
|
||||
use tower_service::Service;
|
||||
|
@ -47,6 +47,18 @@ impl Connector {
|
|||
|
||||
Connector { resolver }
|
||||
}
|
||||
|
||||
pub fn new_service<E>() -> impl Future<Item=Connector, Error=E> {
|
||||
ok(Connector::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for Connector {
|
||||
fn clone(&self) -> Self {
|
||||
Connector {
|
||||
resolver: self.resolver.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Service for Connector {
|
||||
|
|
|
@ -34,6 +34,21 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<F, Req, Resp, E, Fut> Clone for FnService<F, Req, Resp, E, Fut>
|
||||
where
|
||||
F: Fn(Req) -> Fut + Clone,
|
||||
Fut: IntoFuture<Item = Resp, Error = E>,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
FnService {
|
||||
f: self.f.clone(),
|
||||
req: marker::PhantomData,
|
||||
resp: marker::PhantomData,
|
||||
err: marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, Req, Resp, E, Fut> Service for FnService<F, Req, Resp, E, Fut>
|
||||
where
|
||||
F: Fn(Req) -> Fut,
|
||||
|
|
Loading…
Reference in a new issue