Crate iprange [] [src]

iprange is a library for managing IP ranges.

An IpRange is a set of subnets. You can add or remove a Subnet 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.contains("172.16.32.1".parse::<Ipv4Addr>().unwrap()));
    assert!(ip_range.contains("192.168.1.1".parse::<Ipv4Addr>().unwrap()));
}

Currently, this library supports IPv4 only.

Structs

CompactIpv4

A wrapper of u32 to represent an IPv4 address.

IpRange

A set of subnets that supports various operations.

IpRangeIter

An iterator over the subnets in an IpRange.

ParseSubnetError

An error which can be returned when parsing an subnet.

Subnet

Represents a subdivision of an IP network.