From ef396882bc35a97d778e985cd69ebd5181852d8c Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 19 Feb 2020 12:18:01 +0100 Subject: openpgp: Split VerificationResult. - Split VerificationResult into Result. - Fixes #416. --- guide/src/chapter_01.md | 52 ++++++++++++------------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) (limited to 'guide') diff --git a/guide/src/chapter_01.md b/guide/src/chapter_01.md index 0c891aab..75bc6896 100644 --- a/guide/src/chapter_01.md +++ b/guide/src/chapter_01.md @@ -126,17 +126,10 @@ fn main() { # // whether the signature checks out mathematically, we apply # // our policy. # match results.into_iter().next() { -# Some(VerificationResult::GoodChecksum { .. }) => +# Some(Ok(_)) => # good = true, -# Some(VerificationResult::NotAlive { .. }) => -# return Err(failure::err_msg( -# "Good, but not alive signature")), -# Some(VerificationResult::MissingKey { .. }) => -# return Err(failure::err_msg( -# "Missing key to verify signature")), -# Some(VerificationResult::Error { error, .. }) => -# return Err(failure::err_msg( -# format!("Bad signature: {:?}", error))), +# Some(Err(e)) => +# return Err(openpgp::Error::from(e).into()), # None => # return Err(failure::err_msg("No signature")), # } @@ -281,17 +274,10 @@ fn generate() -> openpgp::Result { # // whether the signature checks out mathematically, we apply # // our policy. # match results.into_iter().next() { -# Some(VerificationResult::GoodChecksum { .. }) => +# Some(Ok(_)) => # good = true, -# Some(VerificationResult::NotAlive { .. }) => -# return Err(failure::err_msg( -# "Good, but not alive signature")), -# Some(VerificationResult::MissingKey { .. }) => -# return Err(failure::err_msg( -# "Missing key to verify signature")), -# Some(VerificationResult::Error { error, .. }) => -# return Err(failure::err_msg( -# format!("Bad signature: {:?}", error))), +# Some(Err(e)) => +# return Err(openpgp::Error::from(e).into()), # None => # return Err(failure::err_msg("No signature")), # } @@ -436,17 +422,10 @@ fn sign(policy: &dyn Policy, # // whether the signature checks out mathematically, we apply # // our policy. # match results.into_iter().next() { -# Some(VerificationResult::GoodChecksum { .. }) => +# Some(Ok(_)) => # good = true, -# Some(VerificationResult::NotAlive { .. }) => -# return Err(failure::err_msg( -# "Good, but not alive signature")), -# Some(VerificationResult::MissingKey { .. }) => -# return Err(failure::err_msg( -# "Missing key to verify signature")), -# Some(VerificationResult::Error { error, .. }) => -# return Err(failure::err_msg( -# format!("Bad signature: {:?}", error))), +# Some(Err(e)) => +# return Err(openpgp::Error::from(e).into()), # None => # return Err(failure::err_msg("No signature")), # } @@ -602,17 +581,10 @@ impl<'a> VerificationHelper for Helper<'a> { // whether the signature checks out mathematically, we apply // our policy. match results.into_iter().next() { - Some(VerificationResult::GoodChecksum { .. }) => + Some(Ok(_)) => good = true, - Some(VerificationResult::NotAlive { .. }) => - return Err(failure::err_msg( - "Good, but not alive signature")), - Some(VerificationResult::MissingKey { .. }) => - return Err(failure::err_msg( - "Missing key to verify signature")), - Some(VerificationResult::Error { error, .. }) => - return Err(failure::err_msg( - format!("Bad signature: {:?}", error))), + Some(Err(e)) => + return Err(openpgp::Error::from(e).into()), None => return Err(failure::err_msg("No signature")), } -- cgit v1.2.3