Skip to main content

Crate route_summarization

Crate route_summarization 

Source
Expand description

Aggregate IPv4/IPv6 CIDR prefixes into their minimal covering set.

Inputs are parsed with parse_entry and collected in an Aggregator, which merges overlapping and adjacent ranges and emits the smallest list of CIDR blocks that covers exactly the same addresses.

use route_summarization::Aggregator;

let mut agg = Aggregator::new();
for line in ["10.0.0.0/24", "10.0.1.0/24", "192.0.2.7", "2001:db8::/33", "2001:db8:8000::/33"] {
    agg.add_str(line, false).unwrap();
}
let out: Vec<String> = agg.summarize().iter().map(|p| p.to_string()).collect();
assert_eq!(out, ["10.0.0.0/23", "192.0.2.7", "2001:db8::/32"]);

Structs§

Aggregator
Collects ranges and produces the minimal covering prefix list.
Prefix
A CIDR prefix with no host bits set. Displays host routes (/32, /128) as a bare address.
Range
An inclusive address range within one family. Always valid: start <= end, both within the family’s address space.

Enums§

Family
Address family of a prefix or range.
ParseError
Why an input line was rejected.

Functions§

parse_entry
Parse one input entry into an address range.