ipnet 2.12.2
README badge
[](https://proofs.rs/crate/ipnet?version=2.12.2)Provides types and useful methods for working with IPv4 and IPv6 network addresses, commonly called IP prefixes. The new `IpNet`, `Ipv4Net`, and `Ipv6Net` types build on the existing `IpAddr`, `Ipv4Addr`, and `Ipv6Addr` types already provided in Rust's standard library and align to their design to stay consistent. The module also provides useful traits that extend `Ipv4Addr` and `Ipv6Addr` with methods for `Add`, `Sub`, `BitAnd`, and `BitOr` operations. The module only uses stable feature so it is guaranteed to compile using the stable toolchain.
Reports (1)
Findings (3)
APIs (313)
APIClaims · findings
Functions
pub fn ip_mask_to_prefix(mask: std::net::IpAddr) -> Result<u8, crate::PrefixLenError>1 claimpub fn ipv4_mask_to_prefix(mask: std::net::Ipv4Addr) -> Result<u8, crate::PrefixLenError>1 claimpub fn ipv6_mask_to_prefix(mask: std::net::Ipv6Addr) -> Result<u8, crate::PrefixLenError>1 claimAssociated functions
impl IpNet
pub fn aggregate(networks: &Vec<IpNet>) -> Vec<IpNet>—pub const fn new_assert(ip: IpAddr, prefix_len: u8) -> IpNet1 claimpub fn with_netmask(ip: IpAddr, netmask: IpAddr) -> Result<IpNet, PrefixLenError>1 claimimpl Ipv4AddrRange
impl Ipv4Net
pub fn aggregate(networks: &Vec<Ipv4Net>) -> Vec<Ipv4Net>—pub const fn new_assert(ip: Ipv4Addr, prefix_len: u8) -> Ipv4Net1 claimpub fn with_netmask(ip: Ipv4Addr, netmask: Ipv4Addr) -> Result<Ipv4Net, PrefixLenError>1 claimimpl Ipv4Subnets
impl Ipv6AddrRange
impl Ipv6Net
pub fn aggregate(networks: &Vec<Ipv6Net>) -> Vec<Ipv6Net>—pub const fn new_assert(ip: Ipv6Addr, prefix_len: u8) -> Ipv6Net1 claimpub fn with_netmask(ip: Ipv6Addr, netmask: Ipv6Addr) -> Result<Ipv6Net, PrefixLenError>1 claimimpl Ipv6Subnets
Methods
impl IpNet
pub fn is_sibling(self: &Self, other: &IpNet) -> bool4 claimspub fn max_prefix_len(self: &Self) -> u81 claimpub fn prefix_len(self: &Self) -> u81 claimimpl Ipv4Net
pub fn is_sibling(self: &Self, other: &Ipv4Net) -> bool1 claimpub const fn max_prefix_len(self: &Self) -> u81 claimpub const fn prefix_len(self: &Self) -> u81 claimimpl Ipv6Net
pub fn is_sibling(self: &Self, other: &Ipv6Net) -> bool1 claimpub const fn max_prefix_len(self: &Self) -> u81 claimpub const fn prefix_len(self: &Self) -> u81 claimTraits
trait IpAdd
pub fn saturating_add(self: Self, rhs: RHS) -> <Self as ipnet::ipext::IpAdd>::Output—trait IpBitAnd
pub fn bitand(self: Self, rhs: RHS) -> <Self as ipnet::ipext::IpBitAnd>::Output—trait IpBitOr
pub fn bitor(self: Self, rhs: RHS) -> <Self as ipnet::ipext::IpBitOr>::Output—trait IpSub
pub fn saturating_sub(self: Self, rhs: RHS) -> <Self as ipnet::ipext::IpSub>::Output—Trait implementations
impl core::clone::Clone for …
fn clone11 implementations11 claims
impl core::cmp::Ord for …
fn cmp9 implementations9 claims
impl core::cmp::PartialEq for …
fn eq11 implementations11 claims
impl core::cmp::PartialOrd for …
fn partial_cmp9 implementations9 claims
impl core::convert::From<core::net::ip_addr::IpAddr> for IpNet
impl core::convert::From<core::net::ip_addr::Ipv4Addr> for Ipv4Net
impl core::convert::From<core::net::ip_addr::Ipv6Addr> for Ipv6Net
impl core::convert::From<ipnet::Ipv4AddrRange> for IpAddrRange
impl core::convert::From<ipnet::Ipv4Net> for IpNet
fn from2 implementations1 claim
impl core::convert::From<ipnet::Ipv4Subnets> for IpSubnets
fn from2 implementations1 claim
impl core::convert::From<ipnet::Ipv6AddrRange> for IpAddrRange
impl core::convert::From<ipnet::Ipv6Net> for IpNet
fn from2 implementations1 claim
impl core::convert::From<ipnet::Ipv6Subnets> for IpSubnets
fn from2 implementations1 claim
impl core::default::Default for …
fn default3 implementations3 claims
impl core::fmt::Debug for …
fn fmt11 implementations—
impl core::fmt::Display for …
impl core::hash::Hash for …
fn hash9 implementations—
impl core::iter::traits::double_ended::DoubleEndedIterator for …
fn next_back3 implementations3 claims
impl core::iter::traits::iterator::Iterator for …
fn count3 implementations3 claims
fn last3 implementations3 claims
fn max3 implementations3 claims
fn min3 implementations3 claims
fn next6 implementations6 claims
fn nth3 implementations3 claims
impl core::str::traits::FromStr for …
fn from_str3 implementations—
impl ipnet::IpAdd<u128> for core::net::ip_addr::Ipv6Addr
pub fn saturating_add(self: Self, rhs: u128) -> Ipv6Addr1 claimimpl ipnet::IpAdd<u32> for core::net::ip_addr::Ipv4Addr
pub fn saturating_add(self: Self, rhs: u32) -> Ipv4Addr1 claimimpl ipnet::IpBitAnd for …
fn bitand2 implementations2 claims
impl ipnet::IpBitAnd<u128> for core::net::ip_addr::Ipv6Addr
impl ipnet::IpBitAnd<u32> for core::net::ip_addr::Ipv4Addr
impl ipnet::IpBitOr for …
fn bitor2 implementations2 claims
impl ipnet::IpBitOr<u128> for core::net::ip_addr::Ipv6Addr
impl ipnet::IpBitOr<u32> for core::net::ip_addr::Ipv4Addr
impl ipnet::IpSub for …
fn saturating_sub2 implementations2 claims
impl ipnet::IpSub<u128> for core::net::ip_addr::Ipv6Addr
pub fn saturating_sub(self: Self, rhs: u128) -> Ipv6Addr1 claimimpl ipnet::IpSub<u32> for core::net::ip_addr::Ipv4Addr
pub fn saturating_sub(self: Self, rhs: u32) -> Ipv4Addr1 claim