summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-04-03 20:20:39 +0200
committerNeal H. Walfield <neal@pep.foundation>2020-04-03 20:20:39 +0200
commite2cb547a2d4792c7a0a19fcbb9adf5342ddc7d5e (patch)
tree55062fb09ed0315b5d9c6a33c8797b7d75af014e
parentecc014f857c8064bbca675d79a7815ff8e80df93 (diff)
openpgp: Implement From<Cert> for PacketPile.
-rw-r--r--openpgp/src/cert/mod.rs2
-rw-r--r--openpgp/src/packet_pile.rs8
2 files changed, 9 insertions, 1 deletions
diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs
index 36f05061..751b4143 100644
--- a/openpgp/src/cert/mod.rs
+++ b/openpgp/src/cert/mod.rs
@@ -1224,7 +1224,7 @@ impl Cert {
///
/// This method discards invalid components and bad signatures.
pub fn into_packet_pile(self) -> PacketPile {
- PacketPile::from(self.into_packets().collect::<Vec<Packet>>())
+ self.into()
}
/// Merges `other` into `self`.
diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs
index a3593edd..3539623d 100644
--- a/openpgp/src/packet_pile.rs
+++ b/openpgp/src/packet_pile.rs
@@ -12,6 +12,7 @@ use buffered_reader::BufferedReader;
use crate::Result;
use crate::Error;
use crate::Packet;
+use crate::cert::Cert;
use crate::packet::{self, Container};
use crate::parse::PacketParserResult;
use crate::parse::PacketParserBuilder;
@@ -323,6 +324,13 @@ impl PacketPile {
}
}
+impl From<Cert> for PacketPile {
+ /// Converts the `Cert` into a `PacketPile`.
+ fn from(cert: Cert) -> PacketPile {
+ PacketPile::from(cert.into_packets().collect::<Vec<Packet>>())
+ }
+}
+
impl<'a> TryFrom<PacketParserResult<'a>> for PacketPile {
type Error = anyhow::Error;