diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-09-10 16:14:29 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-09-10 16:18:00 +0200 |
commit | 1ce4cc737838f7c4c1848a0ea6933ee750bd69d6 (patch) | |
tree | 9941a2de2add57ac6ca7a77eb71fd4d6e8777a44 /openpgp | |
parent | dfa4d60f436dfb23896b43766d159bde744ee981 (diff) |
openpgp: Implement TryFrom<&'a Signature> for OnePassSig3.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/packet/one_pass_sig.rs | 6 | ||||
-rw-r--r-- | openpgp/src/parse/stream.rs | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/openpgp/src/packet/one_pass_sig.rs b/openpgp/src/packet/one_pass_sig.rs index 5826eefd..c3f017ed 100644 --- a/openpgp/src/packet/one_pass_sig.rs +++ b/openpgp/src/packet/one_pass_sig.rs @@ -151,8 +151,10 @@ impl From<OnePassSig3> for Packet { } } -impl<'a> From<&'a Signature> for Result<OnePassSig3> { - fn from(s: &'a Signature) -> Self { +impl<'a> std::convert::TryFrom<&'a Signature> for OnePassSig3 { + type Error = failure::Error; + + fn try_from(s: &'a Signature) -> Result<Self> { let issuer = match s.issuer() { Some(i) => i, None => diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs index f75e89bf..cc11e0d9 100644 --- a/openpgp/src/parse/stream.rs +++ b/openpgp/src/parse/stream.rs @@ -10,6 +10,7 @@ //! [verification example]: struct.Verifier.html#example use std::cmp; +use std::convert::TryFrom; use std::collections::HashMap; use std::io::{self, Read}; use std::path::Path; @@ -750,7 +751,7 @@ impl<'a> Transformer<'a> { let mut buf = Vec::new(); for (i, sig) in sigs.iter().rev().enumerate() { - let mut ops = Result::<OnePassSig3>::from(sig)?; + let mut ops = OnePassSig3::try_from(sig)?; if i == sigs.len() - 1 { ops.set_last(true); } |