1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-28 14:30:36 +02:00

service trait takes shared self reference (#247)

This commit is contained in:
fakeshadow
2021-01-22 19:06:22 -08:00
committed by GitHub
parent 874e5f2e50
commit 636cef8868
27 changed files with 225 additions and 219 deletions

View File

@ -79,7 +79,7 @@ where
type Error = Error;
type Future = LocalBoxFuture<'static, Result<TlsStream<T>, Error>>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
if self.conns.available(cx) {
Poll::Ready(Ok(()))
} else {
@ -87,7 +87,7 @@ where
}
}
fn call(&mut self, io: T) -> Self::Future {
fn call(&self, io: T) -> Self::Future {
let guard = self.conns.get();
let this = self.clone();
Box::pin(async move {

View File

@ -75,7 +75,7 @@ where
type Error = SslError;
type Future = AcceptorServiceResponse<T>;
fn poll_ready(&mut self, ctx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&self, ctx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
if self.conns.available(ctx) {
Poll::Ready(Ok(()))
} else {
@ -83,7 +83,7 @@ where
}
}
fn call(&mut self, io: T) -> Self::Future {
fn call(&self, io: T) -> Self::Future {
let ssl_ctx = self.acceptor.context();
let ssl = Ssl::new(ssl_ctx).expect("Provided SSL acceptor was invalid.");
AcceptorServiceResponse {

View File

@ -80,7 +80,7 @@ where
type Error = io::Error;
type Future = AcceptorServiceFut<T>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
if self.conns.available(cx) {
Poll::Ready(Ok(()))
} else {
@ -88,7 +88,7 @@ where
}
}
fn call(&mut self, req: T) -> Self::Future {
fn call(&self, req: T) -> Self::Future {
AcceptorServiceFut {
_guard: self.conns.get(),
fut: self.acceptor.accept(req),

View File

@ -51,7 +51,7 @@ impl<T: Address> Service<Connect<T>> for TcpConnector {
actix_service::always_ready!();
fn call(&mut self, req: Connect<T>) -> Self::Future {
fn call(&self, req: Connect<T>) -> Self::Future {
let port = req.port();
let Connect { req, addr, .. } = req;

View File

@ -146,7 +146,7 @@ impl<T: Address> Service<Connect<T>> for Resolver {
actix_service::always_ready!();
fn call(&mut self, req: Connect<T>) -> Self::Future {
fn call(&self, req: Connect<T>) -> Self::Future {
if !req.addr.is_none() {
ResolverFuture::Connected(Some(req))
} else if let Ok(ip) = req.host().parse() {

View File

@ -80,7 +80,7 @@ impl<T: Address> Service<Connect<T>> for ConnectService {
actix_service::always_ready!();
fn call(&mut self, req: Connect<T>) -> Self::Future {
fn call(&self, req: Connect<T>) -> Self::Future {
ConnectServiceResponse {
fut: ConnectFuture::Resolve(self.resolver.call(req)),
tcp: self.tcp,
@ -149,7 +149,7 @@ impl<T: Address> Service<Connect<T>> for TcpConnectService {
actix_service::always_ready!();
fn call(&mut self, req: Connect<T>) -> Self::Future {
fn call(&self, req: Connect<T>) -> Self::Future {
TcpConnectServiceResponse {
fut: ConnectFuture::Resolve(self.resolver.call(req)),
tcp: self.tcp,

View File

@ -84,7 +84,7 @@ where
actix_service::always_ready!();
fn call(&mut self, stream: Connection<T, U>) -> Self::Future {
fn call(&self, stream: Connection<T, U>) -> Self::Future {
trace!("SSL Handshake start for: {:?}", stream.host());
let (io, stream) = stream.replace(());
let host = stream.host();
@ -202,7 +202,7 @@ impl<T: Address + 'static> Service<Connect<T>> for OpensslConnectService {
actix_service::always_ready!();
fn call(&mut self, req: Connect<T>) -> Self::Future {
fn call(&self, req: Connect<T>) -> Self::Future {
OpensslConnectServiceResponse {
fut1: Some(self.tcp.call(req)),
fut2: None,

View File

@ -84,7 +84,7 @@ where
actix_service::always_ready!();
fn call(&mut self, stream: Connection<T, U>) -> Self::Future {
fn call(&self, stream: Connection<T, U>) -> Self::Future {
trace!("SSL Handshake start for: {:?}", stream.host());
let (io, stream) = stream.replace(());
let host = DNSNameRef::try_from_ascii_str(stream.host())