From c8c7358a08791c51d6370c4bb20194e789210297 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 30 Nov 2021 01:16:15 +0000 Subject: [PATCH] impl default for tcp connector service --- actix-tls/CHANGES.md | 3 +++ actix-tls/src/connect/connector.rs | 2 +- actix-tls/src/connect/tcp.rs | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index 8ab9a711..e0035f37 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -10,12 +10,14 @@ * Implement `Error` for `accept::TlsError` where both types also implement `Error`. [#422] * Implement `Default` for `connect::Resolver`. [#422] * Implement `Error` for `connect::ConnectError`. [#422] +* Implement `Default` for `tcp::{TcpConnector, TcpConnectorService}`. [#423] ### Changed * The crate's default features flags no longer include `uri`. [#422] * Useful re-exports from underlying TLS crates are exposed in a `reexports` modules in all acceptors and connectors. * Convert `connect::ResolverService` from enum to struct. [#422] * Make `ConnectAddrsIter` private. [#422] +* Mark `tcp::{TcpConnector, TcpConnectorService}` structs `#[non_exhaustive]`. [#423] * Rename `accept::native_tls::{NativeTlsAcceptorService => AcceptorService}`. [#422] * Rename `connect::{Address => Host}` trait. [#422] * Rename method `connect::Connection::{host => hostname}`. [#422] @@ -32,6 +34,7 @@ * Remove redundant `connect::Connection::from_parts` method. [#422] [#422]: https://github.com/actix/actix-net/pull/422 +[#423]: https://github.com/actix/actix-net/pull/423 ### Added diff --git a/actix-tls/src/connect/connector.rs b/actix-tls/src/connect/connector.rs index bde9a23a..94d72fe8 100644 --- a/actix-tls/src/connect/connector.rs +++ b/actix-tls/src/connect/connector.rs @@ -34,7 +34,7 @@ impl Connector { /// Build connector service. pub fn service(&self) -> ConnectorService { ConnectorService { - tcp: TcpConnector.service(), + tcp: TcpConnector::default().service(), resolver: self.resolver.service(), } } diff --git a/actix-tls/src/connect/tcp.rs b/actix-tls/src/connect/tcp.rs index 8f566da7..f8f0d3be 100644 --- a/actix-tls/src/connect/tcp.rs +++ b/actix-tls/src/connect/tcp.rs @@ -21,13 +21,14 @@ use tokio_util::sync::ReusableBoxFuture; use super::{connect_addrs::ConnectAddrs, error::ConnectError, ConnectInfo, Connection, Host}; /// TCP connector service factory. -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone, Copy, Default)] +#[non_exhaustive] pub struct TcpConnector; impl TcpConnector { /// Returns a new TCP connector service. pub fn service(&self) -> TcpConnectorService { - TcpConnectorService + TcpConnectorService::default() } } @@ -45,7 +46,8 @@ impl ServiceFactory> for TcpConnector { } /// TCP connector service. -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Default)] +#[non_exhaustive] pub struct TcpConnectorService; impl Service> for TcpConnectorService {