[][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 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]

impl PartialEq<Addr> for Addr[src]

impl PartialOrd<Addr> for Addr[src]

impl Debug for Addr[src]

impl FromStr for Addr[src]

type Err = AddrParseError

The associated error which can be returned from parsing.

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]

impl<T> From<T> for T[src]

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

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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