diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-11-14 12:08:31 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-11-14 12:33:51 +0100 |
commit | a9982139d733e9b1c2c452ce962165971621e466 (patch) | |
tree | ed3ef44ddcef9d0fcdf2eabf70669a7b3acad176 | |
parent | 967f9189aa65e4c8eca988280a52913b5936e9d8 (diff) |
openpgp: Impl TryFrom<&Signature> for OnePassSig.
-rw-r--r-- | openpgp/src/packet/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index 8e72170d..3a773a3a 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -1078,6 +1078,18 @@ impl From<OnePassSig> for Packet { } } +impl<'a> std::convert::TryFrom<&'a Signature> for OnePassSig { + type Error = anyhow::Error; + + fn try_from(s: &'a Signature) -> Result<Self> { + match s.version() { + 4 => one_pass_sig::OnePassSig3::try_from(s).map(Into::into), + n => Err(Error::InvalidOperation( + format!("Unsupported signature version {}", n)).into()), + } + } +} + // Trivial forwarder for singleton enum. impl Deref for OnePassSig { type Target = one_pass_sig::OnePassSig3; |