data IpAddr
IPv4 or IPv6 address, kept in canonical text form (::0:1 is ::1).
Example:
use std.net { IpAddr }
fn main() io {
match IpAddr.parse("::0:1") {
IpAddr ip => print("{ip.toString()} v6={ip.isV6()} loopback={ip.isLoopback()}")
ParseError e => print("bad: {e.msg}")
}
}Output
::1 v6=true loopback=true
@derive(Copy, Eq, Hash)
pub(api) data IpAddrThread safety. immutable; safe to share.
Since. 1.0.0-beta
Fields
pub(api) text: str | The address in canonical text form. |
Methods
parse | (text: str) -> IpAddr | ParseErrorParses numeric IPv4 / IPv6 text (names are not resolved |
loopback | () -> IpAddr127.0.0.1, the IPv4 loopback address. |
loopbackV6 | () -> IpAddr::1, the IPv6 loopback address. |
any | () -> IpAddr0.0.0.0: all IPv4 interfaces. |
anyV6 | () -> IpAddr::: all IPv6 interfaces (and IPv4 ones where the system maps them). |
isV6 | () -> boolWhether the address is IPv6. |
isV4 | () -> boolWhether the address is IPv4. |
isLoopback | () -> boolWhether the address is ::1 or in 127.0.0.0/8. |
toString | () -> strThe canonical text of the address. |
Defined in: std/net/net.oxl:105