Skip to content

Commit a8a8903

Browse files
committed
style: resolve clippy warnings
1 parent 947d5e9 commit a8a8903

3 files changed

Lines changed: 16 additions & 31 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "netem-trace"
3-
version = "0.4.3"
3+
version = "0.4.4"
44
edition = "2021"
55
license = "Apache-2.0"
66
description = "A library for for generating network emulation trace."

examples/plot_traces.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ fn main() {
5050
}
5151

5252
// Export to files
53-
write_bw_series_json(&series, "static_bw.json")
54-
.expect("Failed to write JSON");
55-
write_bw_series_csv(&series, "static_bw.csv")
56-
.expect("Failed to write CSV");
53+
write_bw_series_json(&series, "static_bw.json").expect("Failed to write JSON");
54+
write_bw_series_csv(&series, "static_bw.csv").expect("Failed to write CSV");
5755
println!(" Exported to static_bw.json and static_bw.csv\n");
5856

5957
// Example 2: Sawtooth Bandwidth Trace with Time Cutting
@@ -84,10 +82,8 @@ fn main() {
8482
);
8583
}
8684

87-
write_bw_series_json(&series, "sawtooth_bw.json")
88-
.expect("Failed to write JSON");
89-
write_bw_series_csv(&series, "sawtooth_bw.csv")
90-
.expect("Failed to write CSV");
85+
write_bw_series_json(&series, "sawtooth_bw.json").expect("Failed to write JSON");
86+
write_bw_series_csv(&series, "sawtooth_bw.csv").expect("Failed to write CSV");
9187
println!(" Exported to sawtooth_bw.json and sawtooth_bw.csv\n");
9288

9389
// Example 3: Normalized (Random) Bandwidth Trace
@@ -117,10 +113,8 @@ fn main() {
117113
);
118114
}
119115

120-
write_bw_series_json(&series, "normal_bw.json")
121-
.expect("Failed to write JSON");
122-
write_bw_series_csv(&series, "normal_bw.csv")
123-
.expect("Failed to write CSV");
116+
write_bw_series_json(&series, "normal_bw.json").expect("Failed to write JSON");
117+
write_bw_series_csv(&series, "normal_bw.csv").expect("Failed to write CSV");
124118
println!(" Exported to normal_bw.json and normal_bw.csv\n");
125119

126120
// Example 4: Repeated Pattern
@@ -159,10 +153,8 @@ fn main() {
159153
);
160154
}
161155

162-
write_bw_series_json(&series, "repeated_bw.json")
163-
.expect("Failed to write JSON");
164-
write_bw_series_csv(&series, "repeated_bw.csv")
165-
.expect("Failed to write CSV");
156+
write_bw_series_json(&series, "repeated_bw.json").expect("Failed to write JSON");
157+
write_bw_series_csv(&series, "repeated_bw.csv").expect("Failed to write CSV");
166158
println!(" Exported to repeated_bw.json and repeated_bw.csv\n");
167159

168160
// Example 5: Delay Trace
@@ -188,10 +180,8 @@ fn main() {
188180
);
189181
}
190182

191-
write_delay_series_json(&series, "delay.json")
192-
.expect("Failed to write JSON");
193-
write_delay_series_csv(&series, "delay.csv")
194-
.expect("Failed to write CSV");
183+
write_delay_series_json(&series, "delay.json").expect("Failed to write JSON");
184+
write_delay_series_csv(&series, "delay.csv").expect("Failed to write CSV");
195185
println!(" Exported to delay.json and delay.csv\n");
196186

197187
// Example 6: Per-Packet Delay Trace

src/series.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,7 @@ pub fn write_bw_series_json<P: AsRef<std::path::Path>>(
399399
series: &[BwSeriesPoint],
400400
path: P,
401401
) -> std::io::Result<()> {
402-
let json = serde_json::to_string_pretty(series)
403-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
402+
let json = serde_json::to_string_pretty(series).map_err(std::io::Error::other)?;
404403
std::fs::write(path, json)
405404
}
406405

@@ -438,8 +437,7 @@ pub fn write_delay_series_json<P: AsRef<std::path::Path>>(
438437
series: &[DelaySeriesPoint],
439438
path: P,
440439
) -> std::io::Result<()> {
441-
let json = serde_json::to_string_pretty(series)
442-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
440+
let json = serde_json::to_string_pretty(series).map_err(std::io::Error::other)?;
443441
std::fs::write(path, json)
444442
}
445443

@@ -472,8 +470,7 @@ pub fn write_delay_per_packet_series_json<P: AsRef<std::path::Path>>(
472470
series: &[DelayPerPacketSeriesPoint],
473471
path: P,
474472
) -> std::io::Result<()> {
475-
let json = serde_json::to_string_pretty(series)
476-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
473+
let json = serde_json::to_string_pretty(series).map_err(std::io::Error::other)?;
477474
std::fs::write(path, json)
478475
}
479476

@@ -500,8 +497,7 @@ pub fn write_loss_series_json<P: AsRef<std::path::Path>>(
500497
series: &[LossSeriesPoint],
501498
path: P,
502499
) -> std::io::Result<()> {
503-
let json = serde_json::to_string_pretty(series)
504-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
500+
let json = serde_json::to_string_pretty(series).map_err(std::io::Error::other)?;
505501
std::fs::write(path, json)
506502
}
507503

@@ -542,8 +538,7 @@ pub fn write_duplicate_series_json<P: AsRef<std::path::Path>>(
542538
series: &[DuplicateSeriesPoint],
543539
path: P,
544540
) -> std::io::Result<()> {
545-
let json = serde_json::to_string_pretty(series)
546-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
541+
let json = serde_json::to_string_pretty(series).map_err(std::io::Error::other)?;
547542
std::fs::write(path, json)
548543
}
549544

0 commit comments

Comments
 (0)