/// If the string can be parsed as some kind of IP address, will attempt to
/// match based on that, else fall back to the nodename or serial matches.
If the string can be parsed as some kind of IP address, will attempt to
match based on that, else fall back to the nodename or serial matches.
If the string can be parsed as some kind of IP address will attempt to match based on that else fall back to the nodename or serial matches .
fn from(s: String) -> Self {
        // TODO(raggi): add support for named scopes in the strings
        if s == "" {
            return Self::First;
        }
        if let Ok(saddr) = s.parse::<SocketAddr>() {
            if saddr.port() == 0 {
                return Self::Addr(saddr.into());
            } else {
                let port = saddr.port();
                return Self::AddrPort((saddr.into(), port));
            }
        }
        match s.parse::<IpAddr>() {
            Ok(a) => Self::Addr(TargetAddr::from((a, 0))),
            Err(_) => Self::NodenameOrSerial(s),
        }
    }
fn from ( s : String ) -> Self { // TODO(raggi): add support for named scopes in the strings if s == " " { return Self :: First ; } if let Ok ( saddr ) = s . parse :: < SocketAddr > ( ) { if saddr . port ( ) == 0 { return Self :: Addr ( saddr . into ( ) ) ; } else { let port = saddr . port ( ) ; return Self :: AddrPort ( ( saddr . into ( ) , port ) ) ; } } match s . parse :: < IpAddr > ( ) { Ok ( a ) => Self :: Addr ( TargetAddr :: from ( ( a , 0 ) ) ) , Err ( _ ) => Self :: NodenameOrSerial ( s ) , } }
If the string can be parsed as some kind of IP address, will attempt to
match based on that, else fall back to the nodename or serial matches.
If the string can be parsed as some kind of IP address will attempt to match based on that else fall back to the nodename or serial matches .
s
String