mirror of
https://github.com/ktims/rs-aggregate.git
synced 2025-01-18 01:02:53 -08:00
cleanup: make rayon optional
This commit is contained in:
parent
d5002b9538
commit
48ecb8e793
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rs-aggregate"
|
name = "rs-aggregate"
|
||||||
version = "0.3.1"
|
version = "0.3.2"
|
||||||
authors = ["Keenan Tims <ktims@gotroot.ca>"]
|
authors = ["Keenan Tims <ktims@gotroot.ca>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Aggregate a list of IP prefixes into their minimum equivalent representation"
|
description = "Aggregate a list of IP prefixes into their minimum equivalent representation"
|
||||||
@ -10,11 +10,14 @@ license = "MIT"
|
|||||||
categories = ["network-programming"]
|
categories = ["network-programming"]
|
||||||
exclude = [".github/*", "doc/*", "test-data/*"]
|
exclude = [".github/*", "doc/*", "test-data/*"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["rayon"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.4.6", features = ["derive"] }
|
clap = { version = "4.4.6", features = ["derive"] }
|
||||||
clio = { version = "0.3.4", features = ["clap-parse"] }
|
clio = { version = "0.3.4", features = ["clap-parse"] }
|
||||||
ipnet = "2.8.0"
|
ipnet = "2.8.0"
|
||||||
rayon = "1.8.0"
|
rayon = { version = "1.8.0", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_cmd = "2.0.10"
|
assert_cmd = "2.0.10"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#[cfg(feature = "rayon")]
|
||||||
use rayon::join;
|
use rayon::join;
|
||||||
use std::{
|
use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
@ -24,12 +25,18 @@ impl IpBothRange {
|
|||||||
IpNet::V6(n) => self.v6.push(n),
|
IpNet::V6(n) => self.v6.push(n),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "rayon")]
|
||||||
pub fn simplify(&mut self) {
|
pub fn simplify(&mut self) {
|
||||||
(self.v4, self.v6) = join(
|
(self.v4, self.v6) = join(
|
||||||
|| Ipv4Net::aggregate(&self.v4),
|
|| Ipv4Net::aggregate(&self.v4),
|
||||||
|| Ipv6Net::aggregate(&self.v6),
|
|| Ipv6Net::aggregate(&self.v6),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#[cfg(not(feature = "rayon"))]
|
||||||
|
pub fn simplify(&mut self) {
|
||||||
|
self.v4 = Ipv4Net::aggregate(&self.v4);
|
||||||
|
self.v6 = Ipv6Net::aggregate(&self.v6);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn v4_iter(&self) -> impl Iterator<Item = &Ipv4Net> {
|
pub fn v4_iter(&self) -> impl Iterator<Item = &Ipv4Net> {
|
||||||
self.v4.iter()
|
self.v4.iter()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user