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§

source

fn covering(&self, other: &P) -> IpPrefixCoverage

Checks the coverage of this prefix against a set of adress

  • SameRange means that the two prefixes are equivalent
  • WiderRange means that this prefix includes the other
  • NoCover groups 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

Provided Methods§

source

fn covers(&self, other: &P) -> bool

source

fn covers_striclty(&self, other: &P) -> bool

source

fn covers_equally(&self, other: &P) -> bool

Implementations on Foreign Types§

source§

impl IpPrefixCovering<Ipv4Addr> for Ipv4Net

source§

impl IpPrefixCovering<Ipv6Prefix120> for Ipv6Net

source§

impl IpPrefixCovering<Ipv6Addr> for Ipv6Net

source§

impl IpPrefixCovering<Ipv6Prefix56> for Ipv6Net

source§

impl IpPrefixCovering<Ipv4Prefix> for Ipv4Net

source§

impl IpPrefixCovering<Ipv6Prefix> for Ipv6Net

Implementors§