[−][src]Struct rpki::resources::Addr
An adddress.
This can be both an IPv4 and IPv6 address. It keeps the address internally as a 128 bit unsigned integer. IPv6 address are kept in there in host byte order while IPv4 addresses are kept in the upper four bytes. This makes it possible to count prefix lengths the same way for both addresses, i.e., starting from the top of the raw integer.
Methods
impl Addr
[src]
pub fn from_bits(bits: u128) -> Self
[src]
Creates a new address from 128 raw bits in host byte order.
pub fn from_v4(addr: Ipv4Addr) -> Self
[src]
Creates a new address value for an IPv4 address.
pub fn from_v6(addr: Ipv6Addr) -> Self
[src]
Creates a new address value for an IPv4 address.
pub fn from_v4_str(s: &str) -> Result<Self, AddrParseError>
[src]
Creates a new address from a IPv4 string representation.
pub fn from_v6_str(s: &str) -> Result<Self, AddrParseError>
[src]
Creates a new address from a IPv4 string representation.
pub fn to_bits(self) -> u128
[src]
Returns the raw bits of the underlying integer.
pub fn to_v4(self) -> Ipv4Addr
[src]
Converts the address value into an IPv4 address.
The methods disregards the lower twelve bytes of the value.
pub fn to_v6(self) -> Ipv6Addr
[src]
Converts the address value into an IPv6 address.
pub fn to_bytes(self) -> [u8; 16]
[src]
Returns a byte array for the address.
pub fn to_min(self, prefix_len: u8) -> Self
[src]
Returns an address with all but the first prefix_len
bits cleared.
The first prefix_len
bits are retained. Thus, the returned address
is the smallest address in a prefix of this length.
pub fn to_max(self, prefix_len: u8) -> Self
[src]
Returns an address with all but the first prefix_len
bits set.
The first prefix_len
bits are retained. Thus, the returned address
is the largest address in a prefix of this length.
pub fn fmt_v4(self, f: &mut Formatter) -> Result
[src]
Formats the address as a IPv4 address.
pub fn fmt_v6(self, f: &mut Formatter) -> Result
[src]
Formats the address as a IPv4 address.
Trait Implementations
impl From<u128> for Addr
[src]
impl From<Ipv4Addr> for Addr
[src]
impl From<Ipv6Addr> for Addr
[src]
impl From<IpAddr> for Addr
[src]
impl From<Addr> for u128
[src]
impl From<Addr> for Ipv4Addr
[src]
impl From<Addr> for Ipv6Addr
[src]
impl Clone for Addr
[src]
impl Copy for Addr
[src]
impl Eq for Addr
[src]
impl Ord for Addr
[src]
fn cmp(&self, other: &Addr) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Addr> for Addr
[src]
impl PartialOrd<Addr> for Addr
[src]
fn partial_cmp(&self, other: &Addr) -> Option<Ordering>
[src]
fn lt(&self, other: &Addr) -> bool
[src]
fn le(&self, other: &Addr) -> bool
[src]
fn gt(&self, other: &Addr) -> bool
[src]
fn ge(&self, other: &Addr) -> bool
[src]
impl Debug for Addr
[src]
impl FromStr for Addr
[src]
type Err = AddrParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, AddrParseError>
[src]
impl Hash for Addr
[src]
Auto Trait Implementations
impl Send for Addr
impl Sync for Addr
impl Unpin for Addr
impl UnwindSafe for Addr
impl RefUnwindSafe for Addr
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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, 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,