summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet_pile.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-03-31 11:00:31 +0200
committerJustus Winter <justus@sequoia-pgp.org>2020-03-31 11:52:31 +0200
commit7f4eb0b55bb20b771d8ccfc5e0541ff95f83757c (patch)
tree724fe301502d11c782eed54ec14d4ebb9c4ff5f0 /openpgp/src/packet_pile.rs
parent13da17b51764dfb285d5febdbcdee24a2d6c4021 (diff)
openpgp: Move definition of struct PacketPile.
- Implement Default for PacketPile, add internal accessor for the top-level.
Diffstat (limited to 'openpgp/src/packet_pile.rs')
-rw-r--r--openpgp/src/packet_pile.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs
index 3e0a4cc1..c339095e 100644
--- a/openpgp/src/packet_pile.rs
+++ b/openpgp/src/packet_pile.rs
@@ -10,13 +10,30 @@ use crate::Result;
use crate::Error;
use crate::Packet;
use crate::packet::{self, Container};
-use crate::PacketPile;
use crate::parse::PacketParserResult;
use crate::parse::PacketParserBuilder;
use crate::parse::Parse;
use crate::parse::Cookie;
-
+/// A `PacketPile` holds a deserialized sequence of OpenPGP messages.
+///
+/// To deserialize an OpenPGP usage, use either [`PacketParser`],
+/// [`PacketPileParser`], or [`PacketPile::from_file`] (or related
+/// routines).
+///
+/// Normally, you'll want to convert the `PacketPile` to a Cert or a
+/// `Message`.
+///
+/// [`PacketParser`]: parse/struct.PacketParser.html
+/// [`PacketPileParser`]: parse/struct.PacketPileParser.html
+/// [`PacketPile::from_file`]: struct.PacketPile.html#method.from_file
+#[derive(PartialEq, Clone, Default)]
+pub struct PacketPile {
+ /// At the top level, we have a sequence of packets, which may be
+ /// containers.
+ top_level: Container,
+}
+
impl fmt::Debug for PacketPile {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("PacketPile")
@@ -85,6 +102,11 @@ impl From<Packet> for PacketPile {
}
impl PacketPile {
+ /// Accessor for PacketPileParser.
+ pub(crate) fn top_level_mut(&mut self) -> &mut Container {
+ &mut self.top_level
+ }
+
/// Returns an error if operating on a non-container packet.
fn error() -> crate::Error {
crate::Error::InvalidOperation("Not a container packet".into())