Trait iptrie::IpPrefixCovering
source · pub trait IpPrefixCovering<P> {
// Required method
fn covering(&self, other: &P) -> IpPrefixCoverage;
// Provided methods
fn covers(&self, other: &P) -> bool { ... }
fn covers_striclty(&self, other: &P) -> bool { ... }
fn covers_equally(&self, other: &P) -> bool { ... }
}Expand description
A trait to check if the prefix covers the specified data
Required Methods§
sourcefn covering(&self, other: &P) -> IpPrefixCoverage
fn covering(&self, other: &P) -> IpPrefixCoverage
Checks the coverage of this prefix against a set of adress
SameRangemeans that the two prefixes are equivalentWiderRangemeans that this prefix includes the otherNoCovergroups all the other cases
Difference with PartialEq
Two prefixes could be different but equivalent regarding to the range of addresses they cover.
use ipnet::Ipv4Net;
let a = "1.1.1.1/16".parse::<Ipv4Net>().unwrap();
let b = "1.1.2.2/16".parse::<Ipv4Net>().unwrap();
assert!( a != b ); // since host addr are different
assert! (a.covers_equally(&b) ); // but prefixes are equivalent