Struct ipnet::Emu128
[−]
[src]
pub struct Emu128 { pub hi: u64, pub lo: u64, }
An emulated 128 bit unsigned integer.
This module provides Emu128
, a 128 bit unsigned integer that is
emulated using two u64
types. This is useful for operations on
IPv6 address, which are 128 bit unsigned integers.
Currently Emu128
only implements those operations that are useful
for the Ipv6Net
type. It is not intended to become a full u128
implementation.
Conversion between Ipv6Addr
and Emu128
is provided by a From
and Into
implementation on Emu128
. The into()
method must be
used to convert from an Ipv6Addr
to an Emu128
because it is not
possible to implement From<Emu128> for Ipv6Addr
.
Examples
use std::net::Ipv6Addr; use std::str::FromStr; use ipnet::Emu128; let i1 = Emu128::from(1); // convert from u32 let i2 = Emu128::from([1, 1]); // convert from [u64; 2] let slice: [u64; 2] = i2.into(); // convert into [u64; 2] let a = Ipv6Addr::from_str("fd00::1").unwrap(); let u = Emu128 { hi: 0xfd00_0000_0000_0000, lo: 1 }; let a2: Ipv6Addr = u.into(); let u2: Emu128 = a.into(); assert_eq!(a, a2); assert_eq!(u, u2); assert_eq!(u, Emu128::from(a));
Fields
hi: u64
lo: u64
Methods
impl Emu128
[src]
fn min_value() -> Emu128
[src]
fn max_value() -> Emu128
[src]
fn saturating_add(self, other: Emu128) -> Emu128
[src]
fn saturating_sub(self, other: Emu128) -> Emu128
[src]
fn checked_shl(self, rhs: u8) -> Option<Self>
[src]
fn checked_shr(self, rhs: u8) -> Option<Self>
[src]
fn leading_zeros(self) -> u32
[src]
fn trailing_zeros(self) -> u32
[src]
Trait Implementations
impl Copy for Emu128
[src]
impl Clone for Emu128
[src]
fn clone(&self) -> Emu128
[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 Eq for Emu128
[src]
impl PartialEq for Emu128
[src]
fn eq(&self, __arg_0: &Emu128) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Emu128) -> bool
[src]
This method tests for !=
.
impl Ord for Emu128
[src]
fn cmp(&self, __arg_0: &Emu128) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
[src]
ord_max_min
)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
[src]
ord_max_min
)Compares and returns the minimum of two values. Read more
impl PartialOrd for Emu128
[src]
fn partial_cmp(&self, __arg_0: &Emu128) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Emu128) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Emu128) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Emu128) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Emu128) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Hash for Emu128
[src]
fn hash<__H: Hasher>(&self, __arg_0: &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]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Debug for Emu128
[src]
impl Default for Emu128
[src]
impl Shl<u8> for Emu128
[src]
type Output = Self
The resulting type after applying the <<
operator.
fn shl(self, rhs: u8) -> Emu128
[src]
Performs the <<
operation.
impl Shr<u8> for Emu128
[src]
type Output = Self
The resulting type after applying the >>
operator.
fn shr(self, rhs: u8) -> Emu128
[src]
Performs the >>
operation.
impl BitAnd for Emu128
[src]
type Output = Self
The resulting type after applying the &
operator.
fn bitand(self, rhs: Emu128) -> Emu128
[src]
Performs the &
operation.
impl BitOr for Emu128
[src]
type Output = Self
The resulting type after applying the |
operator.
fn bitor(self, rhs: Emu128) -> Emu128
[src]
Performs the |
operation.