Struct std::net::Ipv6Addr
Re-export from std::net::address::Ipv6Addr
An IPv6 address
Example
use std::net::Ipv6Addr;
let address = Ipv6Addr::from_segments(&[0x2001, 0xdb8, 0, 0, 0, 0, 0, 0x1]);
println!("{}", address); // Prints "2001:db8::1"
Run this example
Fields
-
inner: in6_addr
Methods
impl Ipv6Addr { ... }
-
Create a new IPv6 address from 16-bit segments
-
Create a new IPv6 address from a slice of 16-bit segments
-
fn localhost() -> Ipv6Addr
Localhost address (
::1
) -
fn unspecified() -> Ipv6Addr
Unspecified address (
::
) -
fn from_libc(addr: in6_addr) -> Ipv6Addr
Convert
in6_addr
into an IPv6 address -
Convert IPv6 address to an array of 16-bit segments
-
Extract IPv4 address from an IPv6 address if it's a v4-mapped or v4-compat address
Returns
Option::none()
if the address is not a v4-mapped or v4-compat address. -
Parses an IPv6 address from a string.
Returns
Option::none()
if the address is not a valid IPv6 address.Examples
use std::net::Ipv6Addr; let addr = Ipv6Addr::parse("::1").unwrap(); assert_eq!(addr, Ipv6Addr::localhost());
Run this exampleuse std::net::Ipv6Addr; Ipv6Addr::parse("tota:ly:n0t::ipv6").unwrap(); // panics
Run this example
Mixins
impl Ipv6Addr { ... }
-
-
Returns
false
if arguments are equal,true
otherwise