Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Rust Debug format as an output format when decoding XDR #357

Merged
merged 3 commits into from
Apr 9, 2024
Merged
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
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
Loading