From b9efd4617038953c3a2b25f729706ca8d52b1892 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 1 Dec 2021 14:17:43 +0100 Subject: [PATCH] Inline trivial single-use function Also avoids allocating an extra copy of the host String. --- epp-client/src/config.rs | 7 ------- epp-client/src/connection/registry.rs | 13 +++++++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/epp-client/src/config.rs b/epp-client/src/config.rs index 8559371..3e7f29f 100644 --- a/epp-client/src/config.rs +++ b/epp-client/src/config.rs @@ -27,9 +27,6 @@ //! // Get configuration for the relevant registry section //! let registry = config.registry("verisign").unwrap(); //! -//! // Get EPP host name and port no. -//! let remote = registry.connection_details(); -//! //! // Get username and password //! let credentials = registry.credentials(); //! @@ -73,10 +70,6 @@ pub struct EppClientConnection { } impl EppClientConnection { - /// Returns the EPP host and port no as a tuple - pub fn connection_details(&self) -> (String, u16) { - (self.host.to_string(), self.port) - } /// Returns the EPP username and password as a tuple pub fn credentials(&self) -> (String, String) { (self.username.to_string(), self.password.to_string()) diff --git a/epp-client/src/connection/registry.rs b/epp-client/src/connection/registry.rs index 6991ba8..3b8f9cf 100644 --- a/epp-client/src/connection/registry.rs +++ b/epp-client/src/connection/registry.rs @@ -120,11 +120,12 @@ impl EppConnection { pub async fn epp_connect( registry_creds: &EppClientConnection, ) -> Result, error::Error> { - let (host, port) = registry_creds.connection_details(); + info!( + "Connecting: EPP Server: {} Port: {}", + registry_creds.host, registry_creds.port + ); - info!("Connecting: EPP Server: {} Port: {}", host, port); - - let addr = (host.as_str(), port) + let addr = (registry_creds.host.as_str(), registry_creds.port) .to_socket_addrs()? .next() .ok_or(stdio::ErrorKind::NotFound)?; @@ -184,10 +185,10 @@ pub async fn epp_connect( let connector = TlsConnector::from(Arc::new(config)); let stream = TcpStream::connect(&addr).await?; - let domain = host.as_str().try_into().map_err(|_| { + let domain = registry_creds.host.as_str().try_into().map_err(|_| { stdio::Error::new( stdio::ErrorKind::InvalidInput, - format!("Invalid domain: {}", host), + format!("Invalid domain: {}", registry_creds.host), ) })?;