[−][src]Struct sequoia_openpgp::parse::PacketPileParser
A PacketPileParser
parses an OpenPGP message with the convenience
of PacketPile::from_file
and the flexibility of a PacketParser
.
Like PacketPile::from_file
(and unlike PacketParser
), a
PacketPileParser
parses an OpenPGP message and returns a PacketPile
.
But, unlike PacketPile::from_file
(and like PacketParser
), it
allows the caller to inspect each packet as it is being parsed.
Thus, using a PacketPileParser
, it is possible to decide on a
per-packet basis whether to stream, buffer or drop the packet's
body, whether to recurse into a container, or whether to abort
processing, for example. And, PacketPileParser
conveniently packs
the packets into a PacketPile
.
If old packets don't need to be retained, then PacketParser
should be preferred. If no per-packet processing needs to be
done, then PacketPile::from_file
will be slightly faster.
Examples
let mut ppp = PacketPileParser::from_bytes(message_data)?; let mut ppr = ppp.recurse()?; while let Some(pp) = ppr.as_ref() { eprintln!("{:?}", pp); ppr = ppp.recurse()?; } let message = ppp.finish(); message.pretty_print();
Methods
impl<'a> PacketPileParser<'a>
[src]
pub fn recurse(&mut self) -> Result<&mut PacketParserResult<'a>>
[src]
Finishes parsing the current packet and starts parsing the next one. This function recurses, if possible.
This function finishes parsing the current packet. By default, any unread content is dropped. It then creates a new packet parser for the next packet. If the current packet is a container, this function tries to recurse into it. Otherwise, it returns the following packet.
pub fn next(&mut self) -> Result<&mut PacketParserResult<'a>>
[src]
Finishes parsing the current packet and starts parsing the next one. This function does not recurse.
This function finishes parsing the current packet. By default, any unread content is dropped. It then creates a new packet parser for the following packet. If the current packet is a container, this function does not recurse into the container; it skips any packets that it may contain.
pub fn recursion_depth(&self) -> Option<u8>
[src]
Returns the current packet's recursion depth.
A top-level packet has a recursion depth of 0. Packets in a top-level container have a recursion depth of 1. Etc.
pub fn is_done(&self) -> bool
[src]
Returns whether the message has been completely parsed.
pub fn finish(self) -> PacketPile
[src]
Finishes parsing the message and returns the assembled
PacketPile
.
This function can be called at any time, not only when the
message has been completely parsed. If the packet sequence has not
been completely parsed, this function aborts processing, and
the returned PacketPile
just contains those packets that were
completely processed; the packet that is currently being
processed is not included in the PacketPile
.
Trait Implementations
impl<'a> Debug for PacketPileParser<'a>
[src]
impl<'a> Parse<'a, PacketPileParser<'a>> for PacketPileParser<'a>
[src]
fn from_reader<R: Read + 'a>(reader: R) -> Result<PacketPileParser<'a>>
[src]
Creates a PacketPileParser
to parse the OpenPGP message stored
in the io::Read
object.
fn from_file<P: AsRef<Path>>(path: P) -> Result<PacketPileParser<'a>>
[src]
Creates a PacketPileParser
to parse the OpenPGP message stored
in the file named by path
.
fn from_bytes<D: AsRef<[u8]> + ?Sized>(
data: &'a D
) -> Result<PacketPileParser<'a>>
[src]
data: &'a D
) -> Result<PacketPileParser<'a>>
Creates a PacketPileParser
to parse the OpenPGP message stored
in the provided buffer.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for PacketPileParser<'a>
impl<'a> !Send for PacketPileParser<'a>
impl<'a> !Sync for PacketPileParser<'a>
impl<'a> Unpin for PacketPileParser<'a>
impl<'a> !UnwindSafe for PacketPileParser<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,