/// Parses an address in the form 00010203:1234
///
/// Also supports IPv6
///
/// Panics if unparsable
Parses an address in the form 00010203:1234
Also supports IPv6

Panics if unparsable
Parses an address in the form 00010203 : 1234 Also supports IPv6 Panics if unparsable
fn parse_addressport_str(s: &str) -> SocketAddr {
    let mut las = s.split(':');
    let ip_part = expect!(las.next(), "ip_part");
    let port = expect!(las.next(), "port");
    let port = from_str!(u16, port, 16);
    if ip_part.len() == 8 {
        let bytes = hex::decode(&ip_part).unwrap();
        let ip_u32 = NetworkEndian::read_u32(&bytes);
        let ip = Ipv4Addr::new(
            (ip_u32 & 0xff) as u8,
            ((ip_u32 & 0xff << 8) >> 8) as u8,
            ((ip_u32 & 0xff << 16) >> 16) as u8,
            ((ip_u32 & 0xff << 24) >> 24) as u8,
        );
        SocketAddr::V4(SocketAddrV4::new(ip, port))
    } else if ip_part.len() == 32 {
        let bytes = hex::decode(&ip_part).unwrap();
        let ip_u128 = NetworkEndian::read_u128(&bytes);
        let ip = Ipv6Addr::new(
            (ip_u128 & 0xffff) as u16,
            ((ip_u128 & 0xffff << 16) >> 16) as u16,
            ((ip_u128 & 0xffff << 32) >> 32) as u16,
            ((ip_u128 & 0xffff << 48) >> 48) as u16,
            ((ip_u128 & 0xffff << 64) >> 64) as u16,
            ((ip_u128 & 0xffff << 80) >> 80) as u16,
            ((ip_u128 & 0xffff << 96) >> 96) as u16,
            ((ip_u128 & 0xffff << 112) >> 112) as u16,
        );
        SocketAddr::V6(SocketAddrV6::new(ip, port, 0, 0))
    } else {
        panic!("Unable to parse {:?} as an address:port", s)
    }
}
fn parse_addressport_str ( s : & str ) -> SocketAddr { let mut las = s . split ( ':' ) ; let ip_part = expect ! ( las next ( ) " " ) ; let port = expect ! ( las next ( ) " " ) ; let port = from_str ! ( u16 port 16 ) ; if ip_part . len ( ) == 8 { let bytes = hex :: decode ( & ip_part ) . unwrap ( ) ; let ip_u32 = NetworkEndian :: read_u32 ( & bytes ) ; let ip = Ipv4Addr :: new ( ( ip_u32 & 0xff ) as u8 , ( ( ip_u32 & 0xff << 8 ) >> 8 ) as u8 , ( ( ip_u32 & 0xff << 16 ) >> 16 ) as u8 , ( ( ip_u32 & 0xff << 24 ) >> 24 ) as u8 , ) ; SocketAddr :: V4 ( SocketAddrV4 :: new ( ip , port ) ) } else if ip_part . len ( ) == 32 { let bytes = hex :: decode ( & ip_part ) . unwrap ( ) ; let ip_u128 = NetworkEndian :: read_u128 ( & bytes ) ; let ip = Ipv6Addr :: new ( ( ip_u128 & 0xffff ) as u16 , ( ( ip_u128 & 0xffff << 16 ) >> 16 ) as u16 , ( ( ip_u128 & 0xffff << 32 ) >> 32 ) as u16 , ( ( ip_u128 & 0xffff << 48 ) >> 48 ) as u16 , ( ( ip_u128 & 0xffff << 64 ) >> 64 ) as u16 , ( ( ip_u128 & 0xffff << 80 ) >> 80 ) as u16 , ( ( ip_u128 & 0xffff << 96 ) >> 96 ) as u16 , ( ( ip_u128 & 0xffff << 112 ) >> 112 ) as u16 , ) ; SocketAddr :: V6 ( SocketAddrV6 :: new ( ip , port , 0 , 0 ) ) } else { panic ! ( " " s ) } }
Parses an address in the form 00010203:1234
Also supports IPv6
Parses an address in the form 00010203 : 1234 Also supports IPv6
s
&str