Struct IpAddrV6

Source
pub struct IpAddrV6 { /* private fields */ }
Expand description

Implements IP version 6 style addresses.

Implementations§

Source§

impl IpAddrV6

Source

pub fn new( a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16, ) -> IpAddrV6

Returns a IP-v6 address.

The result will represent the IP address a:b:c:d:e:f:g:h

§Examples
use asyncio::ip::IpAddrV6;

let ip = IpAddrV6::new(0,0,0,0,0,0,0,1);
Source

pub fn with_scope_id( a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16, scope_id: u32, ) -> IpAddrV6

Returns a IP-v6 address with set a scope-id.

The result will represent the IP address a:b:c:d:e:f:g:h%[scope-id]

§Examples
use asyncio::ip::IpAddrV6;

let ip = IpAddrV6::with_scope_id(0,0,0,0,0,0,0,1,0x01);
Source

pub fn any() -> IpAddrV6

Returns a unspecified IP-v6 address.

§Examples
use asyncio::ip::IpAddrV6;

let ip = IpAddrV6::any();
assert_eq!(ip, IpAddrV6::new(0,0,0,0,0,0,0,0));
Source

pub fn loopback() -> IpAddrV6

Returns a loopback IP-v6 address.

§Examples
use asyncio::ip::IpAddrV6;

let ip = IpAddrV6::loopback();
assert_eq!(ip, IpAddrV6::new(0,0,0,0,0,0,0,1));
Source

pub fn from(bytes: [u8; 16], scope_id: u32) -> IpAddrV6

Returns a IP-v6 address from 16-octet bytes.

§Examples
use asyncio::ip::IpAddrV6;

let ip = IpAddrV6::from([0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15], 0);
assert_eq!(ip, IpAddrV6::new(0x0001, 0x0203,0x0405,0x0607,0x0809,0x0A0B, 0x0C0D, 0x0E0F));
Source

pub fn get_scope_id(&self) -> u32

Returns a scope-id.

§Examples
use asyncio::ip::IpAddrV6;

let ip = IpAddrV6::with_scope_id(0,0,0,0,0,0,0,0, 10);
assert_eq!(ip.get_scope_id(), 10);
Source

pub fn set_scope_id(&mut self, scope_id: u32)

Sets a scope-id.

§Examples
use asyncio::ip::IpAddrV6;

let mut ip = IpAddrV6::loopback();
assert_eq!(ip.get_scope_id(), 0);

ip.set_scope_id(0x10);
assert_eq!(ip.get_scope_id(), 16);
Source

pub fn is_unspecified(&self) -> bool

Returns true if this is a unspecified address.

Source

pub fn is_loopback(&self) -> bool

Returns true if this is a loopback address.

Returns true if this is a link-local address.

Source

pub fn is_site_local(&self) -> bool

Returns true if this is a site-local address.

Source

pub fn is_multicast(&self) -> bool

Returns true if this is a some multicast address.

Source

pub fn is_multicast_global(&self) -> bool

Returns true if this is a multicast address for global.

Returns true if this is a multicast address for link-local.

Source

pub fn is_multicast_node_local(&self) -> bool

Returns true if this is a multicast address for node-local.

Source

pub fn is_multicast_org_local(&self) -> bool

Returns true if this is a multicast address for org-local.

Source

pub fn is_multicast_site_local(&self) -> bool

Returns true if this is a multicast address for site-local.

Source

pub fn is_v4_mapped(&self) -> bool

Returns true if this is a mapped IP-v4 address.

Source

pub fn is_v4_compatible(&self) -> bool

Returns true if this is a IP-v4 compatible address.

Source

pub fn as_bytes(&self) -> &[u8; 16]

Retruns a 16 octets array.

Source

pub fn to_v4(&self) -> Option<IpAddrV4>

Retruns a IP-v4 address if this is a convertable address.

Source

pub fn v4_mapped(addr: &IpAddrV4) -> Self

Returns a mapped IP-v4 address.

Ex. 192.168.0.1 => ::ffff:192.168.0.1

Source

pub fn v4_compatible(addr: &IpAddrV4) -> Option<Self>

Returns a IP-v4 compatible address if the addr isn’t in 0.0.0.0, 0.0.0.1.

Ex. 192.168.0.1 => ::192.168.0.1

Trait Implementations§

Source§

impl AddAssign<i64> for IpAddrV6

Source§

fn add_assign(&mut self, rhs: i64)

Performs the += operation. Read more
Source§

impl Clone for IpAddrV6

Source§

fn clone(&self) -> IpAddrV6

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IpAddrV6

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for IpAddrV6

Source§

fn default() -> IpAddrV6

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

impl Display for IpAddrV6

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<[u8; 16]> for IpAddrV6

Source§

fn from(bytes: [u8; 16]) -> Self

Converts to this type from the input type.
Source§

impl FromStr for IpAddrV6

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<IpAddrV6>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for IpAddrV6

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

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

impl<'a, P: Protocol> IntoEndpoint<P> for &'a IpAddrV6

Source§

fn into_endpoint(self, port: u16) -> IpEndpoint<P>

Source§

impl<P: Protocol> IntoEndpoint<P> for IpAddrV6

Source§

fn into_endpoint(self, port: u16) -> IpEndpoint<P>

Source§

impl Ord for IpAddrV6

Source§

fn cmp(&self, other: &IpAddrV6) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for IpAddrV6

Source§

fn eq(&self, other: &IpAddrV6) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for IpAddrV6

Source§

fn partial_cmp(&self, other: &IpAddrV6) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl SubAssign<i64> for IpAddrV6

Source§

fn sub_assign(&mut self, rhs: i64)

Performs the -= operation. Read more
Source§

impl Eq for IpAddrV6

Source§

impl StructuralPartialEq for IpAddrV6

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.