1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! This crate provides [`PrefixSet`], a set-like container for IP prefixes
//! (*not* IP addresses).
//!
//! Sets of prefixes are stored in a binary radix tree structure that provides:
//!
//! - Fast insertion of contiguous prefix ranges in a single traversal,
//! - Iteration over either prefixes or ranges of prefixes, and
//! - Self aggregation on each operation.
//!
//! This is a Rust implementation derived in large part from the internal
//! data-structure used in the widely used [`bgpq3`] tool by Alexandre Snarskii,
//! packaged as a library, and with set-theoretic operations added.
//!
//! # Quickstart
//!
//! ``` rust
//! extern crate prefixset;
//! use prefixset::{Error, Ipv6Prefix, IpPrefixRange, PrefixSet};
//!
//! fn main() -> Result<(), Error> {
//!
//! // create a set by parsing a Vec<&str>
//! let set = vec![
//! "2001:db8::/37",
//! "2001:db8:f00::/37",
//! ]
//! .iter()
//! .map(|s| s.parse::<Ipv6Prefix>())
//! .collect::<Result<PrefixSet<_>, _>>()?;
//!
//! // create a range by parsing a &str and providing the lower
//! // and upper prefix lenth bounds
//! let range = IpPrefixRange::new("2001:db8::/36".parse()?, 37, 37)?;
//!
//! assert_eq!(set.ranges().collect::<Vec<_>>(), vec![range]);
//! Ok(())
//! }
//! ```
//!
//! [`bgpq3`]: https://github.com/snar/bgpq3
//!
extern crate ipnet;
extern crate num;
pub use crateError;
pub use crate;
pub use cratePrefixSet;