[][src]Struct rpki::resources::Addr

pub struct 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 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.

Trait Implementations

impl PartialOrd<Addr> for Addr[src]

impl Copy for Addr[src]

impl PartialEq<Addr> for Addr[src]

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]

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

Performs copy-assignment from source. Read more

impl Ord for Addr[src]

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

Compares and returns the maximum of two values. Read more

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

Compares and returns the minimum of two values. Read more

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

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

Returns max if self is greater than max, and min if self is less than min. Otherwise this will return self. Panics if min > max. Read more

impl Eq for Addr[src]

impl Debug for Addr[src]

impl Hash for Addr[src]

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

Auto Trait Implementations

impl Send for Addr

impl Sync for Addr

Blanket Implementations

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

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

type Owned = T

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.