AddressFamily

Trait AddressFamily 

Source
pub trait AddressFamily:
    Binary
    + Debug
    + Hash
    + Display
    + Eq
    + BitAnd<Output = Self>
    + BitOr<Output = Self>
    + Shr<Self, Output = Self>
    + Shl<Output = Self>
    + Shl<Self, Output = Self>
    + Sub<Output = Self>
    + Copy
    + Ord
    + FromBytes
    + IntoBytes
    + KnownLayout
    + Immutable
    + Unaligned {
    type Inner: Into<Self> + From<u32> + From<u8>;
    type InnerIpAddr;

    const BITS: u8;
Show 14 methods // Required methods fn from_ipaddr(ip_addr: Self::InnerIpAddr) -> Self; fn from_u32(value: u32) -> Self; fn from_u8(value: u8) -> Self; fn zero() -> Self; fn into_bit_span(net: Self, start_bit: u8, len: u8) -> BitSpan; fn add_bit_span(self, len: u8, bs: BitSpan) -> (Self, u8); fn truncate_to_len(self, len: u8) -> Self; fn into_ipaddr(self) -> IpAddr; fn dangerously_truncate_to_u32(self) -> u32; fn checked_shr_or_zero(self, rhs: u32) -> Self; fn checked_shl_or_zero(self, rhs: u32) -> Self; fn checked_shr(self, rhs: u32) -> Option<Self::Inner>; fn checked_shl(self, rhs: u32) -> Option<Self::Inner>; // Provided method fn new(value: Self::Inner) -> Self { ... }
}
Expand description

Trait that defines the AFIs 1 (IPv4) and 2 (IPv6). The address family of an IP address as a Trait.

The idea of this trait is that each family will have a separate type to be able to only take the exact amount of memory needed. Useful when building trees with large amounts of addresses/prefixes. Used by rotonda-store for this purpose.

Required Associated Constants§

Source

const BITS: u8

The number of bits in the byte representation of the family.

Required Associated Types§

Source

type Inner: Into<Self> + From<u32> + From<u8>

The type actually holding the value, u32 for IPv4, and u128 for IPv6.

Source

type InnerIpAddr

The std::net that the value of self belongs to. So, std::net::Ipv4Addr, and std::net::Ipv6Addr for IPv4, and IPv6 respectively.

Required Methods§

Source

fn from_ipaddr(ip_addr: Self::InnerIpAddr) -> Self

Source

fn from_u32(value: u32) -> Self

Source

fn from_u8(value: u8) -> Self

Source

fn zero() -> Self

Source

fn into_bit_span(net: Self, start_bit: u8, len: u8) -> BitSpan

Source

fn add_bit_span(self, len: u8, bs: BitSpan) -> (Self, u8)

Treat self as a prefix and append the given bitspan to it.

Source

fn truncate_to_len(self, len: u8) -> Self

fill the bits after the specified len with zeros. Interpreted as an IP Prefix, this means that self will be truncated to the specified len.

Source

fn into_ipaddr(self) -> IpAddr

Turn self in to a std::net::IpAddr.

Source

fn dangerously_truncate_to_u32(self) -> u32

Truncate self to a u32. For IPv4 this is a NOP. For IPv6 this truncates to 32 bits.

Source

fn checked_shr_or_zero(self, rhs: u32) -> Self

Source

fn checked_shl_or_zero(self, rhs: u32) -> Self

Source

fn checked_shr(self, rhs: u32) -> Option<Self::Inner>

Source

fn checked_shl(self, rhs: u32) -> Option<Self::Inner>

Provided Methods§

Source

fn new(value: Self::Inner) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§