Crate iprange [] [src]

iprange is a library for managing IP ranges.

An IpRange is a set of networks. You can add or remove a Ipv4Net from an IpRange.

It also supports these useful operations:

Here is a simple example:

extern crate iprange;

use std::net::Ipv4Addr;
use iprange::IpRange;

fn main() {
    let mut ip_range = IpRange::new();
    ip_range
        .add("10.0.0.0/8".parse().unwrap())
        .add("172.16.0.0/16".parse().unwrap())
        .add("192.168.1.0/24".parse().unwrap());

    assert!(ip_range.includes("172.16.32.1".parse::<Ipv4Addr>().unwrap()));
    assert!(ip_range.includes("192.168.1.1".parse::<Ipv4Addr>().unwrap()));
}

Currently, this library supports IPv4 only.

Structs

IpRange

A set of networks that supports various operations:

IpRangeIter

An iterator over the networks in an IpRange.

Traits

ToNetwork

Anything that can be converted to Ipv4Net.