Lyricdev
GitHub

enum IpAddr

pub enum IpAddr :: [Equatable, Debug]

Conforms to Equatable, Debug, Display, Parse.

An IP address: version 4's four bytes, or version 6's eight groups of 16 bits.

Variants

V4(uint8, uint8, uint8, uint8)
V6(uint16, uint16, uint16, uint16, uint16, uint16, uint16, uint16)

Methods

fn show(): string

Returns version 4 dotted, 192.0.2.1; version 6 as RFC 5952 writes it — lower case, no leading zero in a group, the longest run of two or more zero groups (the first of equals) as ::, and an IPv4-mapped address with its dotted tail, ::ffff:192.0.2.1.

static fn parse(s: StringView): IpAddr throws ParseError

Parses version 4 dotted — four decimal bytes, none with a leading zero, so nothing is read as octal (RFC 6943 §3.1.1) —, or version 6 in the forms of RFC 4291 §2.2: groups of one to four hex digits, :: once for one or more zero groups, an IPv4 tail in the last 32 bits. A zone (%eth0) is not accepted.

Errors

Throws ParseError: Empty for empty text, Invalid for anything that is neither form.