Struct ipaddr::Ipv4Mask [−][src]
pub struct Ipv4Mask(_);
A valid IPv4 mask.
Methods
impl Ipv4Mask
[src]
impl Ipv4Mask
pub fn prefixlen(&self) -> u32
[src]
pub fn prefixlen(&self) -> u32
Return the mask as a prefix length;
assert_eq!(Ipv4Mask::try_from(0).unwrap().prefixlen(), 0); assert_eq!(Ipv4Mask::try_from(0xffff_ffff).unwrap().prefixlen(), 32); assert_eq!(Ipv4Mask::try_from(0xfff8_0000).unwrap().prefixlen(), 13);
pub fn from_prefixlen(prefixlen: u8) -> Result<Self, InvalidMask>
[src]
pub fn from_prefixlen(prefixlen: u8) -> Result<Self, InvalidMask>
Create an Ipv4Mask
from a prefix length.
assert_eq!(Ipv4Mask::from_prefixlen(0).unwrap(), Ipv4Mask::try_from(0).unwrap()); assert_eq!(Ipv4Mask::from_prefixlen(32).unwrap(), Ipv4Mask::try_from(0xffff_ffff).unwrap()); assert_eq!(Ipv4Mask::from_prefixlen(13).unwrap(), Ipv4Mask::try_from(0xfff8_0000).unwrap());
pub fn to_string(&self) -> String
[src]
pub fn to_string(&self) -> String
Return a human readable representation of the IPv4 mask.
let mask = Ipv4Mask::try_from(0xfff8_0000).unwrap(); assert_eq!(mask.to_string(), "255.248.0.0".to_string());
Trait Implementations
impl From<Ipv4Mask> for Ipv4Address
[src]
impl From<Ipv4Mask> for Ipv4Address
impl<'a> From<&'a Ipv4Mask> for Ipv4Address
[src]
impl<'a> From<&'a Ipv4Mask> for Ipv4Address
impl Copy for Ipv4Mask
[src]
impl Copy for Ipv4Mask
impl Clone for Ipv4Mask
[src]
impl Clone for Ipv4Mask
fn clone(&self) -> Ipv4Mask
[src]
fn clone(&self) -> Ipv4Mask
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Ipv4Mask
[src]
impl PartialEq for Ipv4Mask
fn eq(&self, other: &Ipv4Mask) -> bool
[src]
fn eq(&self, other: &Ipv4Mask) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Ipv4Mask) -> bool
[src]
fn ne(&self, other: &Ipv4Mask) -> bool
This method tests for !=
.
impl Eq for Ipv4Mask
[src]
impl Eq for Ipv4Mask
impl Hash for Ipv4Mask
[src]
impl Hash for Ipv4Mask
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Display for Ipv4Mask
[src]
impl Display for Ipv4Mask
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Debug for Ipv4Mask
[src]
impl Debug for Ipv4Mask
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl AsRef<u32> for Ipv4Mask
[src]
impl AsRef<u32> for Ipv4Mask
impl From<Ipv4Mask> for u32
[src]
impl From<Ipv4Mask> for u32
impl<'a> From<&'a Ipv4Mask> for u32
[src]
impl<'a> From<&'a Ipv4Mask> for u32
impl TryFrom<u32> for Ipv4Mask
[src]
impl TryFrom<u32> for Ipv4Mask
type Error = InvalidMask
try_from
)The type returned in the event of a conversion error.
fn try_from(value: u32) -> Result<Ipv4Mask, Self::Error>
[src]
fn try_from(value: u32) -> Result<Ipv4Mask, Self::Error>
try_from
)Performs the conversion.
impl<'a> TryFrom<&'a u32> for Ipv4Mask
[src]
impl<'a> TryFrom<&'a u32> for Ipv4Mask
type Error = InvalidMask
try_from
)The type returned in the event of a conversion error.
fn try_from(value: &'a u32) -> Result<Ipv4Mask, Self::Error>
[src]
fn try_from(value: &'a u32) -> Result<Ipv4Mask, Self::Error>
try_from
)Performs the conversion.
impl TryFrom<Ipv4Address> for Ipv4Mask
[src]
impl TryFrom<Ipv4Address> for Ipv4Mask
type Error = InvalidMask
try_from
)The type returned in the event of a conversion error.
fn try_from(value: Ipv4Address) -> Result<Ipv4Mask, Self::Error>
[src]
fn try_from(value: Ipv4Address) -> Result<Ipv4Mask, Self::Error>
try_from
)Performs the conversion.
impl<'a> TryFrom<&'a Ipv4Address> for Ipv4Mask
[src]
impl<'a> TryFrom<&'a Ipv4Address> for Ipv4Mask
type Error = InvalidMask
try_from
)The type returned in the event of a conversion error.
fn try_from(value: &'a Ipv4Address) -> Result<Ipv4Mask, Self::Error>
[src]
fn try_from(value: &'a Ipv4Address) -> Result<Ipv4Mask, Self::Error>
try_from
)Performs the conversion.
impl Not for Ipv4Mask
[src]
impl Not for Ipv4Mask
type Output = Ipv4Address
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
fn not(self) -> Self::Output
Performs the unary !
operation.
impl<'a> Not for &'a Ipv4Mask
[src]
impl<'a> Not for &'a Ipv4Mask
type Output = Ipv4Address
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
fn not(self) -> Self::Output
Performs the unary !
operation.
impl LowerHex for Ipv4Mask
[src]
impl LowerHex for Ipv4Mask
impl UpperHex for Ipv4Mask
[src]
impl UpperHex for Ipv4Mask
impl Binary for Ipv4Mask
[src]
impl Binary for Ipv4Mask
impl BitAnd<Ipv4Mask> for Ipv4Address
[src]
impl BitAnd<Ipv4Mask> for Ipv4Address
type Output = Ipv4Address
The resulting type after applying the &
operator.
fn bitand(self, rhs: Ipv4Mask) -> Self::Output
[src]
fn bitand(self, rhs: Ipv4Mask) -> Self::Output
Performs the &
operation.
impl<'a> BitAnd<Ipv4Mask> for &'a Ipv4Address
[src]
impl<'a> BitAnd<Ipv4Mask> for &'a Ipv4Address
type Output = Ipv4Address
The resulting type after applying the &
operator.
fn bitand(self, rhs: Ipv4Mask) -> Self::Output
[src]
fn bitand(self, rhs: Ipv4Mask) -> Self::Output
Performs the &
operation.
impl<'a> BitAnd<&'a Ipv4Mask> for Ipv4Address
[src]
impl<'a> BitAnd<&'a Ipv4Mask> for Ipv4Address
type Output = Ipv4Address
The resulting type after applying the &
operator.
fn bitand(self, rhs: &'a Ipv4Mask) -> Self::Output
[src]
fn bitand(self, rhs: &'a Ipv4Mask) -> Self::Output
Performs the &
operation.
impl<'a, 'b> BitAnd<&'a Ipv4Mask> for &'b Ipv4Address
[src]
impl<'a, 'b> BitAnd<&'a Ipv4Mask> for &'b Ipv4Address
type Output = Ipv4Address
The resulting type after applying the &
operator.
fn bitand(self, rhs: &'a Ipv4Mask) -> Self::Output
[src]
fn bitand(self, rhs: &'a Ipv4Mask) -> Self::Output
Performs the &
operation.
impl FromStr for Ipv4Mask
[src]
impl FromStr for Ipv4Mask