Skip to content

Commit 7f3b4fb

Browse files
nickysnalehander92
authored andcommitted
chore: cargo fmt
1 parent 663bb87 commit 7f3b4fb

File tree

9 files changed

+92
-206
lines changed

9 files changed

+92
-206
lines changed

runtime_tracing/build.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
fn main() {
2-
::capnpc::CompilerCommand::new()
3-
.file("src/trace.capnp")
4-
.run()
5-
.expect("compiling schema")
2+
::capnpc::CompilerCommand::new().file("src/trace.capnp").run().expect("compiling schema")
63
}

runtime_tracing/src/base64.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ pub fn serialize<S: Serializer>(v: &Vec<u8>, s: S) -> Result<S::Ok, S::Error> {
99

1010
pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<u8>, D::Error> {
1111
let base64 = String::deserialize(d)?;
12-
base64::engine::general_purpose::STANDARD.decode(base64.as_bytes()).map_err(serde::de::Error::custom)
12+
base64::engine::general_purpose::STANDARD
13+
.decode(base64.as_bytes())
14+
.map_err(serde::de::Error::custom)
1315
}

runtime_tracing/src/capnptrace.rs

Lines changed: 69 additions & 169 deletions
Large diffs are not rendered by default.

runtime_tracing/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
//! This crate provides the [`Tracer`] type for emitting trace events and a
99
//! collection of serializable structures describing the trace format.
1010
//! The format is documented in `docs/` and the README.
11-
mod tracer;
12-
mod types;
1311
mod base64;
1412
mod capnptrace;
15-
pub use crate::tracer::{TraceReader, NonStreamingTraceWriter, TraceWriter, TraceEventsFileFormat, NONE_TYPE_ID, NONE_VALUE, create_trace_reader, create_trace_writer};
13+
mod tracer;
14+
mod types;
15+
pub use crate::tracer::{
16+
create_trace_reader, create_trace_writer, NonStreamingTraceWriter, TraceEventsFileFormat, TraceReader, TraceWriter, NONE_TYPE_ID, NONE_VALUE,
17+
};
1618
pub use crate::types::*;
1719

1820
pub mod trace_capnp {

runtime_tracing/src/tracer.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ pub trait TraceReader {
1818
fn load_trace_events(&mut self, path: &Path) -> Result<Vec<TraceLowLevelEvent>, Box<dyn Error>>;
1919
}
2020

21-
pub struct JsonTraceReader {
22-
}
21+
pub struct JsonTraceReader {}
2322

2423
impl TraceReader for JsonTraceReader {
2524
fn load_trace_events(&mut self, path: &Path) -> Result<Vec<TraceLowLevelEvent>, Box<dyn Error>> {
@@ -28,8 +27,7 @@ impl TraceReader for JsonTraceReader {
2827
}
2928
}
3029

31-
pub struct BinaryTraceReader {
32-
}
30+
pub struct BinaryTraceReader {}
3331

3432
impl TraceReader for BinaryTraceReader {
3533
fn load_trace_events(&mut self, path: &Path) -> Result<Vec<TraceLowLevelEvent>, Box<dyn Error>> {
@@ -87,7 +85,6 @@ pub trait TraceWriter {
8785
fn finish_writing_trace_paths(&mut self) -> Result<(), Box<dyn Error>>;
8886
}
8987

90-
9188
/// State machine used to record [`TraceLowLevelEvent`]s.
9289
///
9390
/// A `NonStreamingTraceWriter` instance accumulates events in memory and stores them on
@@ -118,7 +115,7 @@ pub struct NonStreamingTraceWriter {
118115
#[derive(Debug, Clone, Copy)]
119116
pub enum TraceEventsFileFormat {
120117
Json,
121-
Binary
118+
Binary,
122119
}
123120

124121
// we ensure in start they are registered with those id-s
@@ -460,14 +457,9 @@ impl TraceWriter for NonStreamingTraceWriter {
460457

461458
pub fn create_trace_reader(format: TraceEventsFileFormat) -> Box<dyn TraceReader> {
462459
match format {
463-
TraceEventsFileFormat::Json => {
464-
Box::new(JsonTraceReader { } )
465-
}
466-
TraceEventsFileFormat::Binary => {
467-
Box::new(BinaryTraceReader { } )
468-
}
460+
TraceEventsFileFormat::Json => Box::new(JsonTraceReader {}),
461+
TraceEventsFileFormat::Binary => Box::new(BinaryTraceReader {}),
469462
}
470-
471463
}
472464

473465
pub fn create_trace_writer(program: &str, args: &[String], format: TraceEventsFileFormat) -> Box<dyn TraceWriter> {

runtime_tracing/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::cmp::Ord;
66
use std::ops;
77
use std::path::PathBuf;
88

9+
use crate::base64;
910
use num_derive::FromPrimitive;
1011
use serde::{Deserialize, Serialize};
1112
use serde_repr::*;
12-
use crate::base64;
1313

1414
// currently, we do assume that we record the whole program
1515
// so, we try to include minimal amount of data,
@@ -474,5 +474,5 @@ pub enum EventLogKind {
474474
Error,
475475
// used for trace events
476476
TraceLogEvent,
477-
EvmEvent
477+
EvmEvent,
478478
}

runtime_tracing/tests/binary_format.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
use runtime_tracing::{create_trace_reader, create_trace_writer, TraceEventsFileFormat};
2-
use std::path::Path;
32
use std::fs;
3+
use std::path::Path;
44

55
#[test]
66
fn test_binary_roundtrip() {
77
let json_path = Path::new("tests/data/trace.json");
88

99
let mut json_reader = create_trace_reader(TraceEventsFileFormat::Json);
10-
let original = json_reader
11-
.load_trace_events(json_path)
12-
.unwrap();
10+
let original = json_reader.load_trace_events(json_path).unwrap();
1311

1412
let bin_path = Path::new("tests/data/trace.bin");
1513

@@ -19,9 +17,7 @@ fn test_binary_roundtrip() {
1917
bin_writer.finish_writing_trace_events().unwrap();
2018

2119
let mut bin_reader = create_trace_reader(TraceEventsFileFormat::Binary);
22-
let tracer2_events = bin_reader
23-
.load_trace_events(bin_path)
24-
.unwrap();
20+
let tracer2_events = bin_reader.load_trace_events(bin_path).unwrap();
2521

2622
fs::remove_file(bin_path).unwrap();
2723

runtime_tracing_cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::path::Path;
22

3+
use crate::fmt_trace_cmd::FmtTraceCommand;
34
use clap::{Args, Parser, Subcommand};
45
use runtime_tracing::{create_trace_reader, create_trace_writer, TraceEventsFileFormat};
5-
use crate::fmt_trace_cmd::FmtTraceCommand;
66
mod fmt_trace_cmd;
77

88
#[derive(Debug, Clone, Args)]
@@ -50,7 +50,7 @@ fn main() {
5050
trace_writer.begin_writing_trace_events(Path::new(&convert_command.output_file)).unwrap();
5151
trace_writer.append_events(&mut trace_events);
5252
trace_writer.finish_writing_trace_events().unwrap();
53-
},
53+
}
5454
RuntimeTracingCliCommand::FormatTrace(fmt_trace_cmd) => {
5555
fmt_trace_cmd::run(fmt_trace_cmd);
5656
}

trace_formatter/src/read_write_json.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ use std::fs;
44
pub fn serialize_file(src_filename: String) -> Value {
55
let file_content = fs::read_to_string(src_filename).expect("Failed to read the file");
66

7-
serde_json::from_str(&file_content)
8-
.expect("Failed to parse the json file that was given as a source")
7+
serde_json::from_str(&file_content).expect("Failed to parse the json file that was given as a source")
98
}
109

1110
pub fn save_to_file(dest_filename: String, json_string: String) {
1211
let mut json_string_copy = json_string.clone();
1312
if !json_string_copy.ends_with('\n') {
1413
json_string_copy.push('\n');
1514
}
16-
fs::write(&dest_filename, json_string_copy).unwrap_or_else(|_| {
17-
panic!("Unable to write to destination file: {}", dest_filename.as_str())
18-
});
15+
fs::write(&dest_filename, json_string_copy).unwrap_or_else(|_| panic!("Unable to write to destination file: {}", dest_filename.as_str()));
1916
}

0 commit comments

Comments
 (0)