Skip to content

Commit

Permalink
make models required and clean up deps
Browse files Browse the repository at this point in the history
  • Loading branch information
digizeph committed Oct 16, 2024
1 parent 98fa324 commit ce66eab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
25 changes: 10 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,26 @@ required-features = ["cli"]

[dependencies]

##############
# BGP models #
##############
ipnet = "2.10"
itertools = "0.13"
log = "0.4"
num_enum = { version = "0.7", features = ["complex-expressions"] }
bitflags = { version = "2.6", features = ["serde"] }

####################
# Core BGP structs #
####################
num_enum = { version = "0.7", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
itertools = { version = "0.13", optional = true }
ipnet = { version = "2.9", optional = true }
bitflags = { version = "2.6", features = ["serde"], optional = true }

#######################
# Parser dependencies #
#######################
bytes = { version = "1.7", optional = true }
hex = { version = "0.4.3", optional = true } # bmp/openbmp parsing
log = { version = "0.4", optional = true }
oneio = { version = "0.17.0", default-features = false, features = ["gz", "bz"] }
oneio = { version = "0.17.0", default-features = false, features = ["gz", "bz"], optional = true }
regex = { version = "1", optional = true } # used in parser filter
chrono = { version = "0.4.38", optional = true } # parser filter
serde_json = { version = "1.0", optional = true } # RIS Live parsing
Expand All @@ -47,19 +51,10 @@ clap = { version = "4.5", features = ["derive"], optional = true }

[features]
default = ["parser", "rustls"]
models = [
"num_enum",
"num_enum/complex-expressions",
"ipnet",
"itertools",
"bitflags",
]
parser = [
"bytes",
"chrono",
"env_logger",
"log",
"models",
"regex",
]
cli = [
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,11 @@ We support normal communities, extended communities, and large communities.
pub mod encoder;
#[cfg(feature = "parser")]
pub mod error;
#[cfg(feature = "models")]
pub mod models;
#[cfg(feature = "parser")]
pub mod parser;

#[cfg(feature = "models")]
pub use models::BgpElem;
#[cfg(feature = "models")]
pub use models::MrtRecord;
#[cfg(feature = "parser")]
pub use parser::*;
3 changes: 3 additions & 0 deletions src/models/network/asn.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "parser")]
use bytes::{BufMut, Bytes, BytesMut};
use std::cmp::Ordering;
use std::fmt::{Debug, Display, Formatter};
Expand Down Expand Up @@ -274,6 +275,7 @@ impl FromStr for Asn {
}
}

#[cfg(feature = "parser")]
impl Asn {
pub fn encode(&self) -> Bytes {
let mut bytes = BytesMut::new();
Expand All @@ -291,6 +293,7 @@ mod tests {
use crate::parser::ReadUtils;
use std::str::FromStr;

#[cfg(feature = "parser")]
#[test]
fn test_asn_encode() {
let asn = Asn::new_32bit(123);
Expand Down
2 changes: 2 additions & 0 deletions src/models/network/prefix.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::models::BgpModelsError;
#[cfg(feature = "parser")]
use bytes::{BufMut, Bytes, BytesMut};
use ipnet::IpNet;
use std::fmt::{Debug, Display, Formatter};
Expand Down Expand Up @@ -36,6 +37,7 @@ impl NetworkPrefix {
NetworkPrefix { prefix, path_id }
}

#[cfg(feature = "parser")]
/// Encodes the IPNet prefix into a byte slice.
///
/// # Arguments
Expand Down

0 comments on commit ce66eab

Please sign in to comment.