mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-25 17:25:18 +02:00
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.
39 lines
854 B
Rust
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,
|
|
}
|
|
}
|
|
}
|