[−][src]Struct bdrck::net::IpNet
An IpNet represents an IP network. Networks are typically identified in CIDR notation, like (for example) "192.0.0.0/24".
Methods
impl IpNet
[src]
pub fn get_ip(&self) -> IpAddr
[src]
Return the network IP. This address will have been normalized, such that any non-masked bits will have been turned off during construction.
pub fn get_mask(&self) -> &[u8]
[src]
Return the network mask, as a byte slice. This slice will always be 16 bytes long, even if this is an IPv4 network.
pub fn apply_mask(&self, ip: IpAddr, invert: bool, set: bool) -> IpAddr
[src]
Apply this network's mask to the given IP address, returning the modified copy.
The "default" behavior is when invert=false and set=false. In this case, any bits which are "0" in the mask are turned off in the given IP address' bytes.
If invert=true, then each bit in the mask is flipped before it is applied - in other words, we apply the inverse mask.
If set=true, then we switch from bitwise AND to bitwise OR, meaning instead of the behavior described above, any bits which are "1" in the mask are turned on in the IP address, and other bits are left unchanged.
pub fn get_one_bits(&self) -> usize
[src]
Returns the number of "1" bits in this network's mask. Although the mask is always 16 bytes long, for IPv4 networks only the last 4 bytes of the mask are considered.
pub fn is_canonical(&self) -> bool
[src]
Returns whether or not this network's mask is "canonical" - i.e., if all of its mask's "1" bits are contiguous (no "0" bits in-between them).
pub fn netmask(&self) -> IpAddr
[src]
Return the netmask IP address for this network.
pub fn broadcast(&self) -> IpAddr
[src]
Return the broadcast IP address for this network.
pub fn contains(&self, ip: IpAddr, strict: bool) -> bool
[src]
Return whether or not the given IP address is contained within this network. If strict=true, then the "network address" and "broadcast address" are both not considered to be "within" this network (this is useful if you want to check if the given IP address is actually usable for a host on the network).
pub fn increment_in(&self, ip: IpAddr, strict: bool) -> Option<IpAddr>
[src]
Increment the given IP address as if with increment_ip(), but returning None if the resulting IP address does not lie within this network. The "strict" parameter behaves as IpNet::contains() describes.
pub fn first(&self) -> Option<IpAddr>
[src]
Return the first IP address which falls within this network.
pub fn last(&self) -> IpAddr
[src]
Return the last non-broadcast IP address which falls within this network.
Trait Implementations
impl Clone for IpNet
[src]
impl Copy for IpNet
[src]
impl Debug for IpNet
[src]
impl<'de> Deserialize<'de> for IpNet
[src]
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
[src]
impl Display for IpNet
[src]
impl Eq for IpNet
[src]
impl FromStr for IpNet
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self>
[src]
impl Hash for IpNet
[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<IpNet> for IpNet
[src]
impl Serialize for IpNet
[src]
impl StructuralEq for IpNet
[src]
impl StructuralPartialEq for IpNet
[src]
Auto Trait Implementations
impl RefUnwindSafe for IpNet
impl Send for IpNet
impl Sync for IpNet
impl Unpin for IpNet
impl UnwindSafe for IpNet
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> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,