Inline trivial single-use function
Also avoids allocating an extra copy of the host String.
This commit is contained in:
parent
d1cf43af46
commit
b9efd46170
|
@ -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())
|
||||
|
|
|
@ -120,11 +120,12 @@ impl EppConnection {
|
|||
pub async fn epp_connect(
|
||||
registry_creds: &EppClientConnection,
|
||||
) -> Result<TlsStream<TcpStream>, 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),
|
||||
)
|
||||
})?;
|
||||
|
||||
|
|
Loading…
Reference in New Issue