Trait iptrie::IpPrefixCovering
source · pub trait IpPrefixCovering<P> {
// Provided method
fn covers(&self, other: &P) -> bool { ... }
}Expand description
A trait to check the prefix coverage
Provided Methods§
sourcefn covers(&self, other: &P) -> bool
fn covers(&self, other: &P) -> bool
Checks the coverage of this prefix against a set of addresses
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 ); // host addr are different
assert! (a.covers(&b) && b.covers(&a)); // but prefixes are equivalent