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