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§
Required Associated Types§
Sourcetype Inner: Into<Self> + From<u32> + From<u8>
type Inner: Into<Self> + From<u32> + From<u8>
The type actually holding the value, u32 for IPv4, and u128 for IPv6.
Sourcetype InnerIpAddr
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§
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
Sourcefn add_bit_span(self, len: u8, bs: BitSpan) -> (Self, u8)
fn add_bit_span(self, len: u8, bs: BitSpan) -> (Self, u8)
Treat self as a prefix and append the given bitspan to it.
Sourcefn truncate_to_len(self, len: u8) -> Self
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.
Sourcefn into_ipaddr(self) -> IpAddr
fn into_ipaddr(self) -> IpAddr
Turn self in to a std::net::IpAddr.
Sourcefn dangerously_truncate_to_u32(self) -> u32
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.
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 Methods§
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.