Struct crusty_core::config::CIP6Addr[][src]

pub struct CIP6Addr(pub Ipv6Addr);

Methods from Deref<Target = Ipv6Addr>

Returns the eight 16-bit segments that make up this address.

Examples

use std::net::Ipv6Addr;

assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).segments(),
           [0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff]);

Returns true for the special ‘unspecified’ address (::).

This property is defined in IETF RFC 4291.

Examples

use std::net::Ipv6Addr;

assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unspecified(), false);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0).is_unspecified(), true);

Returns true if this is a loopback address (::1).

This property is defined in IETF RFC 4291.

Examples

use std::net::Ipv6Addr;

assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_loopback(), false);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0x1).is_loopback(), true);
🔬 This is a nightly-only experimental API. (ip)

Returns true if the address appears to be globally routable.

The following return false:

  • the loopback address
  • link-local and unique local unicast addresses
  • interface-, link-, realm-, admin- and site-local multicast addresses

Examples

#![feature(ip)]

use std::net::Ipv6Addr;

assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_global(), true);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0x1).is_global(), false);
assert_eq!(Ipv6Addr::new(0, 0, 0x1c9, 0, 0, 0xafc8, 0, 0x1).is_global(), true);
🔬 This is a nightly-only experimental API. (ip)

Returns true if this is a unique local address (fc00::/7).

This property is defined in IETF RFC 4193.

Examples

#![feature(ip)]

use std::net::Ipv6Addr;

assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unique_local(), false);
assert_eq!(Ipv6Addr::new(0xfc02, 0, 0, 0, 0, 0, 0, 0).is_unique_local(), true);
🔬 This is a nightly-only experimental API. (ip)

Returns true if the address is a unicast address with link-local scope, as defined in RFC 4291.

A unicast address has link-local scope if it has the prefix fe80::/10, as per RFC 4291 section 2.4. Note that this encompasses more addresses than those defined in RFC 4291 section 2.5.6, which describes “Link-Local IPv6 Unicast Addresses” as having the following stricter format:

| 10 bits  |         54 bits         |          64 bits           |
+----------+-------------------------+----------------------------+
|1111111010|           0             |       interface ID         |
+----------+-------------------------+----------------------------+

So while currently the only addresses with link-local scope an application will encounter are all in fe80::/64, this might change in the future with the publication of new standards. More addresses in fe80::/10 could be allocated, and those addresses will have link-local scope.

Also note that while RFC 4291 section 2.5.3 mentions about the loopback address (::1) that “it is treated as having Link-Local scope”, this does not mean that the loopback address actually has link-local scope and this method will return false on it.

Examples

#![feature(ip)]

use std::net::Ipv6Addr;

// The loopback address (`::1`) does not actually have link-local scope.
assert_eq!(Ipv6Addr::LOCALHOST.is_unicast_link_local(), false);

// Only addresses in `fe80::/10` have link-local scope.
assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_unicast_link_local(), false);
assert_eq!(Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 0).is_unicast_link_local(), true);

// Addresses outside the stricter `fe80::/64` also have link-local scope.
assert_eq!(Ipv6Addr::new(0xfe80, 0, 0, 1, 0, 0, 0, 0).is_unicast_link_local(), true);
assert_eq!(Ipv6Addr::new(0xfe81, 0, 0, 0, 0, 0, 0, 0).is_unicast_link_local(), true);
🔬 This is a nightly-only experimental API. (ip)

Returns true if this is a deprecated unicast site-local address (fec0::/10). The unicast site-local address format is defined in RFC 4291 section 2.5.7 as:

|   10     |
|  bits    |         54 bits         |         64 bits            |
+----------+-------------------------+----------------------------+
|1111111011|        subnet ID        |       interface ID         |
+----------+-------------------------+----------------------------+

Examples

#![feature(ip)]

use std::net::Ipv6Addr;

assert_eq!(
    Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_site_local(),
    false
);
assert_eq!(Ipv6Addr::new(0xfec2, 0, 0, 0, 0, 0, 0, 0).is_unicast_site_local(), true);

Warning

As per RFC 3879, the whole FEC0::/10 prefix is deprecated. New software must not support site-local addresses.

🔬 This is a nightly-only experimental API. (ip)

Returns true if this is an address reserved for documentation (2001:db8::/32).

This property is defined in IETF RFC 3849.

Examples

#![feature(ip)]

use std::net::Ipv6Addr;

assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_documentation(), false);
assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true);
🔬 This is a nightly-only experimental API. (ip)

Returns true if the address is a globally routable unicast address.

The following return false:

  • the loopback address
  • the link-local addresses
  • unique local addresses
  • the unspecified address
  • the address range reserved for documentation

This method returns true for site-local addresses as per RFC 4291 section 2.5.7

The special behavior of [the site-local unicast] prefix defined in [RFC3513] must no longer
be supported in new implementations (i.e., new implementations must treat this prefix as
Global Unicast).

Examples

#![feature(ip)]

use std::net::Ipv6Addr;

assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_unicast_global(), false);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_global(), true);
🔬 This is a nightly-only experimental API. (ip)

Returns the address’s multicast scope if the address is multicast.

Examples

#![feature(ip)]

use std::net::{Ipv6Addr, Ipv6MulticastScope};

assert_eq!(
    Ipv6Addr::new(0xff0e, 0, 0, 0, 0, 0, 0, 0).multicast_scope(),
    Some(Ipv6MulticastScope::Global)
);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).multicast_scope(), None);

Returns true if this is a multicast address (ff00::/8).

This property is defined by IETF RFC 4291.

Examples

use std::net::Ipv6Addr;

assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).is_multicast(), true);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_multicast(), false);
🔬 This is a nightly-only experimental API. (ip)

Converts this address to an IPv4 address if it’s an “IPv4-mapped IPv6 address” defined in IETF RFC 4291 section 2.5.5.2, otherwise returns None.

::ffff:a.b.c.d becomes a.b.c.d. All addresses not starting with ::ffff will return None.

Examples

#![feature(ip)]

use std::net::{Ipv4Addr, Ipv6Addr};

assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).to_ipv4_mapped(), None);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).to_ipv4_mapped(),
           Some(Ipv4Addr::new(192, 10, 2, 255)));
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4_mapped(), None);

Converts this address to an IPv4 address. Returns None if this address is neither IPv4-compatible or IPv4-mapped.

::a.b.c.d and ::ffff:a.b.c.d become a.b.c.d

Examples

use std::net::{Ipv4Addr, Ipv6Addr};

assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).to_ipv4(), None);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).to_ipv4(),
           Some(Ipv4Addr::new(192, 10, 2, 255)));
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4(),
           Some(Ipv4Addr::new(0, 0, 0, 1)));

Returns the sixteen eight-bit integers the IPv6 address consists of.

use std::net::Ipv6Addr;

assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).octets(),
           [255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more