summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet_pile.rs
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 /openpgp/src/packet_pile.rs
parentecc014f857c8064bbca675d79a7815ff8e80df93 (diff)
openpgp: Implement From<Cert> for PacketPile.
Diffstat (limited to 'openpgp/src/packet_pile.rs')
-rw-r--r--openpgp/src/packet_pile.rs8
1 files changed, 8 insertions, 0 deletions
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;