pub struct Aggregator { /* private fields */ }Expand description
Collects ranges and produces the minimal covering prefix list.
Exclusions are subtracted address by address: the summary covers exactly the added addresses minus the excluded ones, whatever the order of calls and however the inputs overlap. A prefix that partly overlaps an exclusion is split around it.
use route_summarization::Aggregator;
let mut agg = Aggregator::new();
agg.add_str("192.0.2.0/24", false).unwrap();
agg.exclude_str("192.0.2.0/25", false).unwrap();
agg.exclude_str("192.0.2.255", false).unwrap();
let out: Vec<String> = agg.summarize().iter().map(|p| p.to_string()).collect();
assert_eq!(out, ["192.0.2.128/26", "192.0.2.192/27", "192.0.2.224/28",
"192.0.2.240/29", "192.0.2.248/30", "192.0.2.252/31", "192.0.2.254"]);Implementations§
Source§impl Aggregator
impl Aggregator
pub fn new() -> Self
pub fn add(&mut self, r: Range)
Sourcepub fn add_str(&mut self, input: &str, spf: bool) -> Result<(), ParseError>
pub fn add_str(&mut self, input: &str, spf: bool) -> Result<(), ParseError>
Parse and add one entry; see parse_entry.
Sourcepub fn exclude(&mut self, r: Range)
pub fn exclude(&mut self, r: Range)
Remove these addresses from the summary, wherever they appear.
Sourcepub fn exclude_str(&mut self, input: &str, spf: bool) -> Result<(), ParseError>
pub fn exclude_str(&mut self, input: &str, spf: bool) -> Result<(), ParseError>
Parse and exclude one entry; see parse_entry.
Trait Implementations§
Source§impl Clone for Aggregator
impl Clone for Aggregator
Source§impl Debug for Aggregator
impl Debug for Aggregator
Auto Trait Implementations§
impl Freeze for Aggregator
impl RefUnwindSafe for Aggregator
impl Send for Aggregator
impl Sync for Aggregator
impl Unpin for Aggregator
impl UnsafeUnpin for Aggregator
impl UnwindSafe for Aggregator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more