Skip to main content

IntoCanonicalIpAddr

Trait IntoCanonicalIpAddr 

pub trait IntoCanonicalIpAddr {
    // Required method
    fn into_canonical_ip_addr(self) -> Self;
}
Available on crate feature net only.
Expand description

Converts an IP address into a canonical representation.

Canonical means:

  • IPv4 stays IPv4.
  • IPv6 stays IPv6, except for IPv4-mapped addresses (::ffff:a.b.c.d, RFC 4291, Section 2.5.5.2), which convert to the embedded IPv4 address.

IPv4-mapped addresses represent IPv4 connectivity exposed through the IPv6 socket API of dual-stack hosts (RFC 4038, Section 4.2); they never appear on the wire as IPv6 and are not routable as IPv6 (IANA registry). Connecting to one is therefore always IPv4 wire traffic, and dialing the embedded IPv4 address directly is the only form that also works on hosts without (working) dual-stack IPv6 sockets — e.g. Windows, where sockets default to IPV6_V6ONLY.

Required Methods§

fn into_canonical_ip_addr(self) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl IntoCanonicalIpAddr for IpAddr

§

impl IntoCanonicalIpAddr for SocketAddr

Implementors§