summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-01-20 09:58:07 +0100
committerNeal H. Walfield <neal@pep.foundation>2020-01-20 09:58:07 +0100
commit692bb2b27b2fa9b0b18de4d4ad7d4016ac485b4f (patch)
treebf34264f7ccfc6d387293796081b7bca45c538e3
parent542c64110b3f25482b6b5f1fe74c3132f317ca49 (diff)
openpgp: Simplify code.
- Structure the code better.
-rw-r--r--tool/src/commands/mod.rs53
1 files changed, 25 insertions, 28 deletions
diff --git a/tool/src/commands/mod.rs b/tool/src/commands/mod.rs
index 01264cbb..7dd6869a 100644
--- a/tool/src/commands/mod.rs
+++ b/tool/src/commands/mod.rs
@@ -245,32 +245,6 @@ impl<'a> VHelper<'a> {
fn print_sigs(&mut self, results: &[VerificationResult]) {
use self::VerificationResult::*;
for result in results {
- if let Error { sig, error } = result {
- let issuer = sig.get_issuers().iter().nth(0)
- .expect("key has an issuer")
- .to_string();
- let what = match sig.level() {
- 0 => "checksum".into(),
- n => format!("level {} notarizing checksum", n),
- };
- eprintln!("Error verifying {} from {}: {}",
- what, issuer, error);
- self.broken_signatures += 1;
- continue;
- }
- if let MissingKey { sig } = result {
- let issuer = sig.get_issuers().iter().nth(0)
- .expect("missing key checksum has an issuer")
- .to_string();
- let what = match sig.level() {
- 0 => "checksum".into(),
- n => format!("level {} notarizing checksum", n),
- };
- eprintln!("No key to check {} from {}", what, issuer);
- self.unknown_checksums += 1;
- continue;
- }
-
let (issuer, level) = match result {
GoodChecksum { sig, ka, .. } =>
(ka.key().keyid(), sig.level()),
@@ -279,8 +253,31 @@ impl<'a> VHelper<'a> {
.map(|i| i.into())
.unwrap_or(KeyID::wildcard()),
sig.level()),
- MissingKey { .. } => unreachable!("handled above"),
- Error { .. } => unreachable!("handled above"),
+ MissingKey { sig } => {
+ let issuer = sig.get_issuers().get(0)
+ .expect("missing key checksum has an issuer")
+ .to_string();
+ let what = match sig.level() {
+ 0 => "checksum".into(),
+ n => format!("level {} notarizing checksum", n),
+ };
+ eprintln!("No key to check {} from {}", what, issuer);
+ self.unknown_checksums += 1;
+ continue;
+ }
+ Error { sig, error } => {
+ let issuer = sig.get_issuers().get(0)
+ .expect("key has an issuer")
+ .to_string();
+ let what = match sig.level() {
+ 0 => "checksum".into(),
+ n => format!("level {} notarizing checksum", n),
+ };
+ eprintln!("Error verifying {} from {}: {}",
+ what, issuer, error);
+ self.broken_signatures += 1;
+ continue;
+ }
};
let trusted = self.trusted.contains(&issuer);