Struct klickhouse::Ipv6[][src]

pub struct Ipv6(pub Ipv6Addr);
Expand description

Wrapper type for Clickhouse IPv6 type.

Methods from Deref<Target = Ipv6Addr>

pub const LOCALHOST: Ipv6Addr1.30.0[src]

pub const UNSPECIFIED: Ipv6Addr1.30.0[src]

pub const fn segments(&self) -> [u16; 8]1.0.0 (const: 1.50.0)[src]

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]);

pub const fn is_unspecified(&self) -> bool1.7.0 (const: 1.50.0)[src]

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);

pub const fn is_loopback(&self) -> bool1.7.0 (const: 1.50.0)[src]

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);

pub const fn is_global(&self) -> bool[src]

🔬 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);

pub const fn is_unique_local(&self) -> bool[src]

🔬 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 link-local address (fe80::/64).

A common misconception is to think that “unicast link-local addresses start with fe80::”, but IETF RFC 4291 actually defines a stricter format for these addresses:

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

This method validates the format defined in the RFC and won’t recognize addresses like fe80:0:0:1:: or fe81:: as unicast link-local addresses. If you need a less strict validation, use Ipv6Addr::is_unicast_link_local() instead.

Examples

#![feature(ip)]

use std::net::Ipv6Addr;

let ip = Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 0);
assert!(ip.is_unicast_link_local_strict());

let ip = Ipv6Addr::new(0xfe80, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff);
assert!(ip.is_unicast_link_local_strict());

let ip = Ipv6Addr::new(0xfe80, 0, 0, 1, 0, 0, 0, 0);
assert!(!ip.is_unicast_link_local_strict());
assert!(ip.is_unicast_link_local());

let ip = Ipv6Addr::new(0xfe81, 0, 0, 0, 0, 0, 0, 0);
assert!(!ip.is_unicast_link_local_strict());
assert!(ip.is_unicast_link_local());

See also

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

Returns true if the address is a unicast link-local address (fe80::/10).

This method returns true for addresses in the range reserved by [RFC 4291 section 2.4], i.e. addresses with the following format:

|   10     |
|  bits    |         54 bits         |          64 bits           |
+----------+-------------------------+----------------------------+
|1111111010|    arbitratry value     |       interface ID         |
+----------+-------------------------+----------------------------+

As a result, this method considers addresses such as fe80:0:0:1:: or fe81:: to be unicast link-local addresses, whereas Ipv6Addr::is_unicast_link_local_strict() does not. If you need a strict validation fully compliant with the RFC, use Ipv6Addr::is_unicast_link_local_strict() instead.

Examples

#![feature(ip)]

use std::net::Ipv6Addr;

let ip = Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 0);
assert!(ip.is_unicast_link_local());

let ip = Ipv6Addr::new(0xfe80, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff);
assert!(ip.is_unicast_link_local());

let ip = Ipv6Addr::new(0xfe80, 0, 0, 1, 0, 0, 0, 0);
assert!(ip.is_unicast_link_local());
assert!(!ip.is_unicast_link_local_strict());

let ip = Ipv6Addr::new(0xfe81, 0, 0, 0, 0, 0, 0, 0);
assert!(ip.is_unicast_link_local());
assert!(!ip.is_unicast_link_local_strict());

See also

pub const fn is_unicast_site_local(&self) -> bool[src]

🔬 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.

pub const fn is_documentation(&self) -> bool[src]

🔬 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);

pub const fn is_unicast_global(&self) -> bool[src]

🔬 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);

pub const fn multicast_scope(&self) -> Option<Ipv6MulticastScope>[src]

🔬 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);

pub const fn is_multicast(&self) -> bool1.7.0 (const: 1.50.0)[src]

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);

pub const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr>[src]

🔬 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);

pub const fn to_ipv4(&self) -> Option<Ipv4Addr>1.0.0 (const: 1.50.0)[src]

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)));

pub const fn octets(&self) -> [u8; 16]1.12.0 (const: 1.32.0)[src]

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

impl Clone for Ipv6[src]

fn clone(&self) -> Ipv6[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Ipv6[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for Ipv6[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

impl Deref for Ipv6[src]

type Target = Ipv6Addr

The resulting type after dereferencing.

fn deref(&self) -> &Self::Target[src]

Dereferences the value.

impl Display for Ipv6[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl From<Ipv6Addr> for Ipv6[src]

fn from(x: Ipv6Addr) -> Self[src]

Performs the conversion.

impl FromSql for Ipv6[src]

fn from_sql(type_: &Type, value: Value) -> Result<Self>[src]

impl Hash for Ipv6[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl Into<Ipv6Addr> for Ipv6[src]

fn into(self) -> Ipv6Addr[src]

Performs the conversion.

impl Ord for Ipv6[src]

fn cmp(&self, other: &Ipv6) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<Ipv6> for Ipv6[src]

fn eq(&self, other: &Ipv6) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Ipv6) -> bool[src]

This method tests for !=.

impl PartialOrd<Ipv6> for Ipv6[src]

fn partial_cmp(&self, other: &Ipv6) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl ToSql for Ipv6[src]

fn to_sql(self) -> Result<Value>[src]

impl Copy for Ipv6[src]

impl Eq for Ipv6[src]

impl StructuralEq for Ipv6[src]

impl StructuralPartialEq for Ipv6[src]

Auto Trait Implementations

impl RefUnwindSafe for Ipv6

impl Send for Ipv6

impl Sync for Ipv6

impl Unpin for Ipv6

impl UnwindSafe for Ipv6

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.