Struct iptrie::Ipv4Prefix
source · pub struct Ipv4Prefix { /* private fields */ }Expand description
An Ipv4 prefix similar to Ipv4Net but with trailing bits
guaranteed to equal 0
Implementations§
source§impl Ipv4Prefix
impl Ipv4Prefix
sourcepub fn new(addr: Ipv4Addr, len: u8) -> Result<Self, IpPrefixError>
pub fn new(addr: Ipv4Addr, len: u8) -> Result<Self, IpPrefixError>
Build a new prefix.
All the bits greater than the prefix length are set to `0``. If the specified length is greater than the maximum allowed, an error is returned.
Example
use std::net::{Ipv4Addr, Ipv6Addr};
use ipnet::PrefixLenError;
let ipv4 = "1.2.3.4".parse::<Ipv4Addr>().unwrap();
let ipv6 = "1:2:3:4::".parse::<Ipv6Addr>().unwrap();
assert!( Ipv4Prefix::new(ipv4, 12).is_ok());
assert_eq!( Ipv4Prefix::new(ipv4, 64), Err(IpPrefixError::PrefixLenError));Trait Implementations§
source§impl Clone for Ipv4Prefix
impl Clone for Ipv4Prefix
source§fn clone(&self) -> Ipv4Prefix
fn clone(&self) -> Ipv4Prefix
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for Ipv4Prefix
impl Debug for Ipv4Prefix
source§impl Default for Ipv4Prefix
impl Default for Ipv4Prefix
source§fn default() -> Ipv4Prefix
fn default() -> Ipv4Prefix
Returns the “default value” for a type. Read more
source§impl Display for Ipv4Prefix
impl Display for Ipv4Prefix
source§impl From<Ipv4Addr> for Ipv4Prefix
impl From<Ipv4Addr> for Ipv4Prefix
source§impl From<Ipv4Net> for Ipv4Prefix
impl From<Ipv4Net> for Ipv4Prefix
source§impl From<Ipv4Prefix> for Ipv4Net
impl From<Ipv4Prefix> for Ipv4Net
source§fn from(value: Ipv4Prefix) -> Self
fn from(value: Ipv4Prefix) -> Self
Converts to this type from the input type.
source§impl FromStr for Ipv4Prefix
impl FromStr for Ipv4Prefix
source§impl Hash for Ipv4Prefix
impl Hash for Ipv4Prefix
source§impl IpPrefix for Ipv4Prefix
impl IpPrefix for Ipv4Prefix
source§fn bitslot_trunc(&self) -> Self::Slot
fn bitslot_trunc(&self) -> Self::Slot
The inner slot with all the masked bits set to 0. Read more
source§impl IpPrefixCovering<Ipv4Addr> for Ipv4Prefix
impl IpPrefixCovering<Ipv4Addr> for Ipv4Prefix
source§impl IpPrefixCovering<Ipv4Net> for Ipv4Prefix
impl IpPrefixCovering<Ipv4Net> for Ipv4Prefix
source§impl IpPrefixCovering<Ipv4Prefix> for Ipv4Net
impl IpPrefixCovering<Ipv4Prefix> for Ipv4Net
source§impl PartialEq<Ipv4Prefix> for Ipv4Prefix
impl PartialEq<Ipv4Prefix> for Ipv4Prefix
source§fn eq(&self, other: &Ipv4Prefix) -> bool
fn eq(&self, other: &Ipv4Prefix) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Copy for Ipv4Prefix
impl Eq for Ipv4Prefix
impl StructuralEq for Ipv4Prefix
impl StructuralPartialEq for Ipv4Prefix
Auto Trait Implementations§
impl RefUnwindSafe for Ipv4Prefix
impl Send for Ipv4Prefix
impl Sync for Ipv4Prefix
impl Unpin for Ipv4Prefix
impl UnwindSafe for Ipv4Prefix
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more