Expand description
A specification of a CIDR block, containing an address and a variable-length subnet masking prefix length.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Ipv4(Ipv4Cidr)
Ipv6(Ipv6Cidr)
Implementations
sourceimpl Cidr
impl Cidr
sourcepub fn new(addr: Address, prefix_len: u8) -> Cidr
pub fn new(addr: Address, prefix_len: u8) -> Cidr
Create a CIDR block from the given address and prefix length.
Panics
This function panics if the given address is unspecified, or the given prefix length is invalid for the given address.
sourcepub fn prefix_len(&self) -> u8
pub fn prefix_len(&self) -> u8
Return the prefix length of this CIDR block.
sourcepub fn contains_addr(&self, addr: &Address) -> bool
pub fn contains_addr(&self, addr: &Address) -> bool
Query whether the subnetwork described by this CIDR block contains the given address.
sourcepub fn contains_subnet(&self, subnet: &Cidr) -> bool
pub fn contains_subnet(&self, subnet: &Cidr) -> bool
Query whether the subnetwork described by this CIDR block contains the subnetwork described by the given CIDR block.
Trait Implementations
sourceimpl Hash for Cidr
impl Hash for Cidr
sourcefn hash<__H: Hasher>(&self, state: &mut __H)
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher]. Read more
1.3.0fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
sourceimpl Ord for Cidr
impl Ord for Cidr
sourceimpl PartialOrd<Cidr> for Cidr
impl PartialOrd<Cidr> for Cidr
sourcefn partial_cmp(&self, other: &Cidr) -> Option<Ordering>
fn partial_cmp(&self, other: &Cidr) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0fn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl Copy for Cidr
impl Eq for Cidr
impl StructuralEq for Cidr
impl StructuralPartialEq for Cidr
Auto Trait Implementations
impl RefUnwindSafe for Cidr
impl Send for Cidr
impl Sync for Cidr
impl Unpin for Cidr
impl UnwindSafe for Cidr
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more