Files
libsignal/rust/message-backup/src/bin/validator/args.rs
Alex Konradi dc7c4eab1f Test validation of encrypted message backup files
Add a utility binary that compresses and encrypts backup files per the spec. 
Use the encryptor binary to encrypt the unencrypted test case file and include 
it as an additional golden test. Check that, in addition to calling via the 
library, the binary also accepts valid test files.
2024-01-24 09:38:28 -05:00

39 lines
854 B
Rust

//
// Copyright 2024 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//
pub(crate) enum ParseVerbosity {
None,
PrintOneLine,
PrintPretty,
}
fn print_oneline(message: &dyn std::fmt::Debug) {
eprintln!("{message:?}")
}
fn print_pretty(message: &dyn std::fmt::Debug) {
eprintln!("{message:#?}")
}
impl ParseVerbosity {
pub(crate) fn into_visitor(self) -> Option<fn(&dyn std::fmt::Debug)> {
match self {
ParseVerbosity::None => None,
ParseVerbosity::PrintOneLine => Some(print_oneline),
ParseVerbosity::PrintPretty => Some(print_pretty),
}
}
}
impl From<u8> for ParseVerbosity {
fn from(value: u8) -> Self {
match value {
0 => Self::None,
1 => Self::PrintOneLine,
2.. => Self::PrintPretty,
}
}
}