Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ anyhow = "1"
bgpkit-broker = "0.7.0-beta.5"
env_logger = "0.11"
kafka = "0.10.0"
tungstenite = "0.24.0"
tokio-tungstenite = "0.24.0"
tungstenite = "0.27.0"
tokio-tungstenite = "0.27.0"
tokio = { version = "1", features = ["full"] }
futures-util = "0.3.30"
criterion = { version = "0.5.1", features = ["html_reports"] }
Expand Down Expand Up @@ -145,3 +145,7 @@ required-features = ["serde"]
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ target }.tar.gz"
pkg-fmt = "tgz"


[lints.clippy]
uninlined_format_args = "allow"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn main() {

// subscribe to messages from one collector
let msg = json!({"type": "ris_subscribe", "data": {"host": "rrc21"}}).to_string();
socket.send(Message::Text(msg)).unwrap();
socket.send(Message::Text(msg.into())).unwrap();

loop {
let msg = socket.read().expect("Error reading message").to_string();
Expand Down
2 changes: 1 addition & 1 deletion benches/bench_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn benchmark(c: &mut Criterion) {
programs_to_test.push((program, path));
}
Err(err) => {
println!("Unable to locate executable for {}: {}", name, err);
println!("Unable to locate executable for {name}: {err}");
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions benches/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn download_test_data() {
),
};

if format!("{:x}", computed_checksum).as_str() == checksum {
if format!("{computed_checksum:x}").as_str() == checksum {
continue;
}
}
Expand All @@ -75,8 +75,8 @@ pub fn download_test_data() {

match download_file(url, &data_file_path) {
Ok(download_checksum) => {
if format!("{:x}", download_checksum).as_str() != checksum {
println!("MD5 checksum for downloaded file ({:x}) does not match expected checksum ({:?}).", download_checksum, checksum);
if format!("{download_checksum:x}").as_str() != checksum {
println!("MD5 checksum for downloaded file ({download_checksum:x}) does not match expected checksum ({checksum:?}).");
println!("Perhaps a different file is being used?");

panic!("Unable to find expected test data file")
Expand All @@ -96,7 +96,7 @@ fn md5_checksum_for_file<P: AsRef<Path>>(path: P) -> io::Result<Digest> {
let mut file = File::open(path)?;

io::copy(&mut file, &mut context)?;
Ok(context.compute())
Ok(context.finalize())
}

struct HashingWriter<W> {
Expand Down Expand Up @@ -130,7 +130,7 @@ fn download_file<P: AsRef<Path>>(url: &str, target: P) -> io::Result<Digest> {
io::copy(&mut reader, &mut writer)?;
writer.flush()?;

Ok(writer.hasher.compute())
Ok(writer.hasher.finalize())
}

pub fn test_data_dir() -> PathBuf {
Expand Down
8 changes: 4 additions & 4 deletions examples/bmp_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ fn handle_client(mut stream: TcpStream) {
// Convert the received data to a hexadecimal string
let hex_string = buffer[..bytes_read]
.iter()
.map(|b| format!("{:02X}", b))
.map(|b| format!("{b:02X}"))
.collect::<Vec<String>>()
.join(" ");
println!("Received data (hex): {}", hex_string);
println!("Received data (hex): {hex_string}");

let mut data = Bytes::from(buffer[..bytes_read].to_vec());
while data.remaining() > 0 {
Expand All @@ -36,7 +36,7 @@ fn handle_client(mut stream: TcpStream) {
}
}
Err(e) => {
eprintln!("Error reading from socket: {}", e);
eprintln!("Error reading from socket: {e}");
break;
}
}
Expand All @@ -58,7 +58,7 @@ fn main() {
child_thread.join().expect("Thread panicked");
}
Err(e) => {
eprintln!("Error accepting connection: {}", e);
eprintln!("Error accepting connection: {e}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/count_elems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ use bgpkit_parser::BgpkitParser;
fn main() {
let url = "http://archive.routeviews.org/bgpdata/2021.10/UPDATES/updates.20211001.0000.bz2";
let count = BgpkitParser::new(url).unwrap().into_iter().count();
println!("{}", count);
println!("{count}");
}
5 changes: 1 addition & 4 deletions examples/mrt_filter_archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ fn main() {
// make sure to properly flush bytes from writer
drop(mrt_writer);

println!(
"Found and archived {} MRT records, {} BGP messages",
records_count, elems_count
);
println!("Found and archived {records_count} MRT records, {elems_count} BGP messages");

let elems = bgpkit_parser::BgpkitParser::new(OUTPUT_FILE)
.unwrap()
Expand Down
6 changes: 3 additions & 3 deletions examples/real-time-ris-live-websocket-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn main() {
let msg = RisSubscribe::new().host("rrc21");
let (mut write, mut read) = ws_stream.split();
write
.send(Message::Text(msg.to_json_string()))
.send(Message::Text(msg.to_json_string().into()))
.await
.unwrap();

Expand All @@ -30,11 +30,11 @@ async fn main() {
match parse_ris_live_message(msg_str.as_str()) {
Ok(elems) => {
for elem in elems {
println!("{}", elem);
println!("{elem}");
}
}
Err(err) => {
eprintln!("{}", err);
eprintln!("{err}");
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions examples/real-time-ris-live-websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ fn main() {

// subscribe to messages from one collector
let msg = RisSubscribe::new().host("rrc21");
socket.send(Message::Text(msg.to_json_string())).unwrap();
socket
.send(Message::Text(msg.to_json_string().into()))
.unwrap();

loop {
let msg = socket.read().expect("Error reading message").to_string();
Expand All @@ -24,11 +26,11 @@ fn main() {
match parse_ris_live_message(msg.as_str()) {
Ok(elems) => {
for elem in elems {
println!("{}", elem);
println!("{elem}");
}
}
Err(error) => {
println!("{:?}", error);
println!("{error:?}");
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn main() {
let mut parser = match parser_opt {
Ok(p) => p,
Err(err) => {
eprintln!("{}", err);
eprintln!("{err}");
std::process::exit(1);
}
};
Expand Down Expand Up @@ -186,8 +186,8 @@ fn main() {
records_count += 1;
elems_count += elementor.record_to_elems(record).len();
}
println!("total records: {}", records_count);
println!("total elems: {}", elems_count);
println!("total records: {records_count}");
println!("total elems: {elems_count}");
}
(false, true) => {
println!("total records: {}", parser.into_record_iter().count());
Expand Down Expand Up @@ -216,7 +216,7 @@ fn main() {
};
if let Err(e) = writeln!(stdout, "{}", &output_str) {
if e.kind() != std::io::ErrorKind::BrokenPipe {
eprintln!("{}", e);
eprintln!("{e}");
}
std::process::exit(1);
}
Expand Down
14 changes: 7 additions & 7 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ impl Error for ParserErrorWithBytes {}
impl Display for ParserError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
ParserError::IoError(e) => write!(f, "Error: {}", e),
ParserError::EofError(e) => write!(f, "Error: {}", e),
ParserError::ParseError(s) => write!(f, "Error: {}", s),
ParserError::TruncatedMsg(s) => write!(f, "Error: {}", s),
ParserError::Unsupported(s) => write!(f, "Error: {}", s),
ParserError::IoError(e) => write!(f, "Error: {e}"),
ParserError::EofError(e) => write!(f, "Error: {e}"),
ParserError::ParseError(s) => write!(f, "Error: {s}"),
ParserError::TruncatedMsg(s) => write!(f, "Error: {s}"),
ParserError::Unsupported(s) => write!(f, "Error: {s}"),
ParserError::EofExpected => write!(f, "Error: reach end of file"),
#[cfg(feature = "oneio")]
ParserError::OneIoError(e) => write!(f, "Error: {}", e),
ParserError::FilterError(e) => write!(f, "Error: {}", e),
ParserError::OneIoError(e) => write!(f, "Error: {e}"),
ParserError::FilterError(e) => write!(f, "Error: {e}"),
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn main() {

// subscribe to messages from one collector
let msg = json!({"type": "ris_subscribe", "data": {"host": "rrc21"}}).to_string();
socket.send(Message::Text(msg)).unwrap();
socket.send(Message::Text(msg.into())).unwrap();

loop {
let msg = socket.read().expect("Error reading message").to_string();
Expand Down Expand Up @@ -406,8 +406,6 @@ We support normal communities, extended communities, and large communities.
html_logo_url = "https://raw.githubusercontent.com/bgpkit/assets/main/logos/icon-transparent.png",
html_favicon_url = "https://raw.githubusercontent.com/bgpkit/assets/main/logos/favicon.ico"
)]
#![allow(clippy::new_without_default)]
#![allow(clippy::needless_range_loop)]

#[cfg(feature = "parser")]
pub mod encoder;
Expand Down
8 changes: 4 additions & 4 deletions src/models/bgp/attributes/aspath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,21 +764,21 @@ impl Display for AsPath {
AsPathSegment::AsSequence(v) | AsPathSegment::ConfedSequence(v) => {
let mut asn_iter = v.iter();
if let Some(first_element) = asn_iter.next() {
write!(f, "{}", first_element)?;
write!(f, "{first_element}")?;

for asn in asn_iter {
write!(f, " {}", asn)?;
write!(f, " {asn}")?;
}
}
}
AsPathSegment::AsSet(v) | AsPathSegment::ConfedSet(v) => {
write!(f, "{{")?;
let mut asn_iter = v.iter();
if let Some(first_element) = asn_iter.next() {
write!(f, "{}", first_element)?;
write!(f, "{first_element}")?;

for asn in asn_iter {
write!(f, ",{}", asn)?;
write!(f, ",{asn}")?;
}
}
write!(f, "}}")?;
Expand Down
2 changes: 1 addition & 1 deletion src/models/bgp/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ mod tests {
assert!(!aspath_attr.is_optional());

for attr in attributes.iter() {
println!("{:?}", attr);
println!("{attr:?}");
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/models/bgp/attributes/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ mod tests {
#[test]
fn test_display() {
let origin = Origin::IGP;
assert_eq!(format!("{}", origin), "IGP");
assert_eq!(format!("{origin}"), "IGP");
let origin = Origin::EGP;
assert_eq!(format!("{}", origin), "EGP");
assert_eq!(format!("{origin}"), "EGP");
let origin = Origin::INCOMPLETE;
assert_eq!(format!("{}", origin), "INCOMPLETE");
assert_eq!(format!("{origin}"), "INCOMPLETE");
}
}
Loading