[−][src]Struct sgx_tstd::net::Ipv6Addr
An IPv6 address.
IPv6 addresses are defined as 128-bit integers in IETF RFC 4291. They are usually represented as eight 16-bit segments.
See IpAddr
for a type encompassing both IPv4 and IPv6 addresses.
The size of an Ipv6Addr
struct may vary depending on the target operating
system.
Textual representation
Ipv6Addr
provides a FromStr
implementation. There are many ways to represent
an IPv6 address in text, but in general, each segments is written in hexadecimal
notation, and segments are separated by :
. For more information, see
IETF RFC 5952.
Methods
impl Ipv6Addr
[src]
pub const fn new(
a: u16,
b: u16,
c: u16,
d: u16,
e: u16,
f: u16,
g: u16,
h: u16
) -> Ipv6Addr
[src]
a: u16,
b: u16,
c: u16,
d: u16,
e: u16,
f: u16,
g: u16,
h: u16
) -> Ipv6Addr
Creates a new IPv6 address from eight 16-bit segments.
The result will represent the IP address a:b:c:d:e:f:g:h
.
pub const LOCALHOST: Self
[src]
An IPv6 address representing localhost: ::1
.
pub const UNSPECIFIED: Self
[src]
An IPv6 address representing the unspecified address: ::
pub fn segments(&self) -> [u16; 8]
[src]
Returns the eight 16-bit segments that make up this address.
pub fn is_unspecified(&self) -> bool
[src]
Returns true
for the special 'unspecified' address (::).
This property is defined in IETF RFC 4291.
pub fn is_loopback(&self) -> bool
[src]
Returns true
if this is a loopback address (::1).
This property is defined in IETF RFC 4291.
pub fn is_global(&self) -> bool
[src]
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
pub fn is_unique_local(&self) -> bool
[src]
Returns true
if this is a unique local address (fc00::/7
).
This property is defined in IETF RFC 4193.
pub fn is_unicast_link_local_strict(&self) -> bool
[src]
Returns true
if the address is a unicast link-local address (fe80::/64
).
A common mis-conception is to think that "unicast link-local addresses start with
fe80::
", but the 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 the following
addresses such as fe80:0:0:1::
or fe81::
as unicast link-local addresses for example.
If you need a less strict validation use is_unicast_link_local()
instead.
See also
pub fn is_unicast_link_local(&self) -> bool
[src]
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 consider addresses such as fe80:0:0:1::
or fe81::
to be
unicast link-local addresses, whereas is_unicast_link_local_strict()
does not. If you
need a strict validation fully compliant with the RFC, use
is_unicast_link_local_strict()
.
See also
pub fn is_unicast_site_local(&self) -> bool
[src]
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 |
+----------+-------------------------+----------------------------+
Warning
As per RFC 3879, the whole FEC0::/10
prefix is
deprecated. New software must not support site-local
addresses.
pub fn is_documentation(&self) -> bool
[src]
Returns true
if this is an address reserved for documentation
(2001:db8::/32).
This property is defined in IETF RFC 3849.
pub fn is_unicast_global(&self) -> bool
[src]
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).
pub fn multicast_scope(&self) -> Option<Ipv6MulticastScope>
[src]
Returns the address's multicast scope if the address is multicast.
pub fn is_multicast(&self) -> bool
[src]
Returns true
if this is a multicast address (ff00::/8).
This property is defined by IETF RFC 4291.
pub fn to_ipv4(&self) -> Option<Ipv4Addr>
[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
pub const fn octets(&self) -> [u8; 16]
[src]
Returns the sixteen eight-bit integers the IPv6 address consists of.
Trait Implementations
impl Clone for Ipv6Addr
[src]
fn clone(&self) -> Ipv6Addr
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Ipv6Addr
[src]
impl Debug for Ipv6Addr
[src]
impl Display for Ipv6Addr
[src]
impl Eq for Ipv6Addr
[src]
impl From<[u16; 8]> for Ipv6Addr
[src]
impl From<[u8; 16]> for Ipv6Addr
[src]
impl From<Ipv6Addr> for IpAddr
[src]
impl From<Ipv6Addr> for u128
[src]
impl From<u128> for Ipv6Addr
[src]
impl FromStr for Ipv6Addr
[src]
type Err = AddrParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Ipv6Addr, AddrParseError>
[src]
impl Hash for Ipv6Addr
[src]
fn hash<H: Hasher>(&self, s: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Ipv6Addr
[src]
fn cmp(&self, other: &Ipv6Addr) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<IpAddr> for Ipv6Addr
[src]
impl PartialEq<Ipv6Addr> for Ipv6Addr
[src]
impl PartialEq<Ipv6Addr> for IpAddr
[src]
impl PartialOrd<IpAddr> for Ipv6Addr
[src]
fn partial_cmp(&self, other: &IpAddr) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<Ipv6Addr> for Ipv6Addr
[src]
fn partial_cmp(&self, other: &Ipv6Addr) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<Ipv6Addr> for IpAddr
[src]
Auto Trait Implementations
impl RefUnwindSafe for Ipv6Addr
impl Send for Ipv6Addr
impl Sync for Ipv6Addr
impl Unpin for Ipv6Addr
impl UnwindSafe for Ipv6Addr
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,