From 2c9b91b366f2bdf496745d8a9c869922e6c7204d Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 13 Mar 2019 15:55:20 -0700 Subject: [PATCH] add specific constructors --- actix-connect/src/connect.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/actix-connect/src/connect.rs b/actix-connect/src/connect.rs index 970f7b26..0c871350 100644 --- a/actix-connect/src/connect.rs +++ b/actix-connect/src/connect.rs @@ -52,9 +52,17 @@ impl Connect<(&'static str, u16)> { } } -impl Connect<(String, u16)> { +impl Connect<()> { /// Create new `Connect` instance. - pub fn new(host: String, port: u16) -> Connect<(String, u16)> { + pub fn from_string(host: String, port: u16) -> Connect<(String, u16)> { + Connect { + req: (host, port), + addr: None, + } + } + + /// Create new `Connect` instance. + pub fn from_static(host: &'static str, port: u16) -> Connect<(&'static str, u16)> { Connect { req: (host, port), addr: None, @@ -62,7 +70,7 @@ impl Connect<(String, u16)> { } /// Create `Connect` instance by spliting the string by ':' and convert the second part to u16 - pub fn with>(host: T) -> Result, ConnectError> { + pub fn from_str>(host: T) -> Result, ConnectError> { let mut parts_iter = host.as_ref().splitn(2, ':'); let host = parts_iter.next().ok_or(ConnectError::InvalidInput)?; let port_str = parts_iter.next().unwrap_or("");