Skip to content

Commit

Permalink
Add the Rust Debug format as an output format when decoding XDR (#357)
Browse files Browse the repository at this point in the history
* Add the Rust Debug format as an output format when decoding XDR

* fmt
  • Loading branch information
leighmcculloch authored Apr 9, 2024
1 parent 31923a1 commit a80c899
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cli/decode.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
fmt::Debug,
fs::File,
io::{stdin, Read},
path::PathBuf,
Expand Down Expand Up @@ -63,6 +64,8 @@ impl Default for InputFormat {
pub enum OutputFormat {
Json,
JsonFormatted,
RustDebug,
RustDebugFormatted,
}

impl Default for OutputFormat {
Expand Down Expand Up @@ -138,10 +141,12 @@ impl Cmd {
}
}

fn out(&self, v: &impl Serialize) -> Result<(), Error> {
fn out(&self, v: &(impl Serialize + Debug)) -> Result<(), Error> {
match self.output {
OutputFormat::Json => println!("{}", serde_json::to_string(v)?),
OutputFormat::JsonFormatted => println!("{}", serde_json::to_string_pretty(v)?),
OutputFormat::RustDebug => println!("{v:?}"),
OutputFormat::RustDebugFormatted => println!("{v:#?}"),
}
Ok(())
}
Expand Down

0 comments on commit a80c899

Please sign in to comment.