pub struct Ipv6Prefix { /* private fields */ }Expand description
An Ipv4 prefix similar to Ipv6Net but with trailing bits
guaranteed to equal 0
Implementations§
Source§impl Ipv6Prefix
impl Ipv6Prefix
Sourcepub fn new(addr: Ipv6Addr, len: u8) -> Result<Self, IpPrefixError>
pub fn new(addr: Ipv6Addr, 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!( Ipv6Prefix::new(ipv6, 78).is_ok());
assert_eq!( Ipv6Prefix::new(ipv6, 133), Err(IpPrefixError::PrefixLenError));Trait Implementations§
Source§impl Clone for Ipv6Prefix
impl Clone for Ipv6Prefix
Source§fn clone(&self) -> Ipv6Prefix
fn clone(&self) -> Ipv6Prefix
Returns a duplicate 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 Ipv6Prefix
impl Debug for Ipv6Prefix
Source§impl Default for Ipv6Prefix
impl Default for Ipv6Prefix
Source§fn default() -> Ipv6Prefix
fn default() -> Ipv6Prefix
Returns the “default value” for a type. Read more
Source§impl Display for Ipv6Prefix
impl Display for Ipv6Prefix
Source§impl From<Ipv6Addr> for Ipv6Prefix
impl From<Ipv6Addr> for Ipv6Prefix
Source§impl From<Ipv6Net> for Ipv6Prefix
impl From<Ipv6Net> for Ipv6Prefix
Source§impl From<Ipv6NetPrefix> for Ipv6Prefix
impl From<Ipv6NetPrefix> for Ipv6Prefix
Source§fn from(value: Ipv6NetPrefix) -> Self
fn from(value: Ipv6NetPrefix) -> Self
Converts to this type from the input type.
Source§impl From<Ipv6Prefix> for IpNet
impl From<Ipv6Prefix> for IpNet
Source§fn from(value: Ipv6Prefix) -> Self
fn from(value: Ipv6Prefix) -> Self
Converts to this type from the input type.
Source§impl From<Ipv6Prefix> for Ipv6Net
impl From<Ipv6Prefix> for Ipv6Net
Source§fn from(value: Ipv6Prefix) -> Self
fn from(value: Ipv6Prefix) -> Self
Converts to this type from the input type.
Source§impl FromStr for Ipv6Prefix
impl FromStr for Ipv6Prefix
Source§impl Hash for Ipv6Prefix
impl Hash for Ipv6Prefix
Source§impl IpPrefix for Ipv6Prefix
impl IpPrefix for Ipv6Prefix
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<Ipv6Addr> for Ipv6Prefix
impl IpPrefixCovering<Ipv6Addr> for Ipv6Prefix
Source§impl IpPrefixCovering<Ipv6Net> for Ipv6Prefix
impl IpPrefixCovering<Ipv6Net> for Ipv6Prefix
Source§impl IpPrefixCovering<Ipv6NetPrefix> for Ipv6Prefix
impl IpPrefixCovering<Ipv6NetPrefix> for Ipv6Prefix
Source§impl IpPrefixCovering<Ipv6Prefix> for Ipv6Net
impl IpPrefixCovering<Ipv6Prefix> for Ipv6Net
Source§impl IpPrefixCovering<Ipv6Prefix> for Ipv6NetPrefix
impl IpPrefixCovering<Ipv6Prefix> for Ipv6NetPrefix
Source§impl IpPrefixShortening for Ipv6Prefix
impl IpPrefixShortening for Ipv6Prefix
Source§impl IpPrivatePrefix for Ipv6Prefix
impl IpPrivatePrefix for Ipv6Prefix
fn is_private(&self) -> bool
Source§impl IpRootPrefix for Ipv6Prefix
impl IpRootPrefix for Ipv6Prefix
Source§impl Ord for Ipv6Prefix
impl Ord for Ipv6Prefix
Source§fn cmp(&self, other: &Ipv6Prefix) -> Ordering
fn cmp(&self, other: &Ipv6Prefix) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq<Ipv6Net> for Ipv6Prefix
impl PartialEq<Ipv6Net> for Ipv6Prefix
Source§impl PartialEq<Ipv6NetPrefix> for Ipv6Prefix
impl PartialEq<Ipv6NetPrefix> for Ipv6Prefix
Source§impl PartialEq<Ipv6Prefix> for Ipv6Net
impl PartialEq<Ipv6Prefix> for Ipv6Net
Source§impl PartialEq<Ipv6Prefix> for Ipv6NetPrefix
impl PartialEq<Ipv6Prefix> for Ipv6NetPrefix
Source§impl PartialEq for Ipv6Prefix
impl PartialEq for Ipv6Prefix
Source§impl PartialOrd for Ipv6Prefix
impl PartialOrd for Ipv6Prefix
Source§impl TryFrom<Ipv6Prefix> for Ipv6NetPrefix
impl TryFrom<Ipv6Prefix> for Ipv6NetPrefix
Source§type Error = IpPrefixError
type Error = IpPrefixError
The type returned in the event of a conversion error.
impl Copy for Ipv6Prefix
impl Eq for Ipv6Prefix
impl StructuralPartialEq for Ipv6Prefix
Auto Trait Implementations§
impl Freeze for Ipv6Prefix
impl RefUnwindSafe for Ipv6Prefix
impl Send for Ipv6Prefix
impl Sync for Ipv6Prefix
impl Unpin for Ipv6Prefix
impl UnwindSafe for Ipv6Prefix
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