[−][src]Struct ipstuff::MaskedIpv4
Fields
ip: Ipv4Addr
mask: Ipv4Mask
Methods
impl MaskedIpv4
[src]
pub fn new(ip: Ipv4Addr, mask: Ipv4Mask) -> Self
[src]
Constructs a MaskedIpv4 from the provided ip and mask.
pub fn cidr(ip: Ipv4Addr, mask_len: u8) -> Self
[src]
Constructs a MaskedIpv4 from the provided ip and mask length.
Panics
Will panic if provided length > 32
pub fn from_cidr_str(s: &str) -> Option<Self>
[src]
Constructs a new MaskedIpv4 from the provided CIDR string.
pub fn from_network_str(s: &str) -> Option<Self>
[src]
Constructs a new MaskedIpv4 from the provided IP and subnet mask. There must be exactly one space between the IP and mask.
pub fn to_cidr_string(&self) -> String
[src]
Returns a String with the IP and mask in CIDR format. Shortcut for format!("{:#}", self)
pub fn to_network_string(&self) -> String
[src]
Returns a String with the IP and mask in dotted decimal format. Shortcut for format!("{}", self)
pub fn network_address(&self) -> Ipv4Addr
[src]
Returns the network adderss by setting all host bits to 0.
pub fn network(&self) -> MaskedIpv4
[src]
Constructs a new MaskedIpv4 using the network address and mask of this MaskedIpv4.
pub fn is_network_address(&self) -> bool
[src]
Returns true if all host bits in the IP are 0. Always returns false if the mask length is 31 or 32.
pub fn broadcast_address(&self) -> Ipv4Addr
[src]
Returns the broadcast address by setting all host bits to 1.
pub fn is_broadcast_address(&self) -> bool
[src]
Returns true if all host bits in the IP are 1. Always returns false if the mask length is 31 or 32.
pub fn network_bits(&self) -> u8
[src]
Returns the number of network bits. That is, the length of the mask.
pub fn host_bits(&self) -> u8
[src]
Returns the number of host bits. That is, the number of 0 bits in the mask.
pub fn host_count(&self) -> usize
[src]
Returns the number of host addresses in the network.
Panics
Will panic if usize is not large enough to hold the host count.
pub fn host_count_u64(&self) -> u64
[src]
Returns the number of host addresses in the network as u64. Unlike host_count, this will never panic.
pub fn network_count(&self, len: u8) -> usize
[src]
Returns the number of networks of the provided mask length will fit in this network.
Panics
Will panic if the provided length is > 32, or if the number of networks does not fit in usize
pub fn network_count_u64(&self, len: u8) -> u64
[src]
Returns the number of networks of the provided mask length will fit in this network as u64. Unlike network_count, this will not panic due to overflow. May still panic if the provided length is too long.
Panics
Will panic if the provided length is > 32
Trait Implementations
impl Clone for MaskedIpv4
[src]
fn clone(&self) -> MaskedIpv4
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for MaskedIpv4
[src]
impl Debug for MaskedIpv4
[src]
impl Display for MaskedIpv4
[src]
impl Eq for MaskedIpv4
[src]
impl FromStr for MaskedIpv4
[src]
type Err = InvalidMaskedIpv4
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, InvalidMaskedIpv4>
[src]
impl Hash for MaskedIpv4
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<MaskedIpv4> for MaskedIpv4
[src]
fn eq(&self, other: &MaskedIpv4) -> bool
[src]
fn ne(&self, other: &MaskedIpv4) -> bool
[src]
impl StructuralEq for MaskedIpv4
[src]
impl StructuralPartialEq for MaskedIpv4
[src]
Auto Trait Implementations
impl RefUnwindSafe for MaskedIpv4
impl Send for MaskedIpv4
impl Sync for MaskedIpv4
impl Unpin for MaskedIpv4
impl UnwindSafe for MaskedIpv4
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,