Enum sequoia_openpgp::packet::Body
source · pub enum Body {
Unprocessed(Vec<u8>),
Processed(Vec<u8>),
Structured(Vec<Packet>),
}
Expand description
A packet’s body holds either unprocessed bytes, processed bytes, or packets.
We conceptually divide packets into two parts: the header and the body. Whereas the header is read eagerly when the packet is deserialized, the body is only read on demand.
A packet’s body is stored here either when configured via
PacketParserBuilder::buffer_unread_content
, when one of the
PacketPile
deserialization routines is used, or on demand for
a particular packet using the
PacketParser::buffer_unread_content
method.
There are three different types of packets:
- Some packets have an unprocessed body. The
Literal
data packet wraps unstructured plaintext, and theUnknown
packet contains data that we failed to process, say because we didn’t support the packet’s version.
- Some packets are containers. If the parser does not parse the
packet’s child, either because the caller used
PacketParser::next
to get the next packet, or the maximum recursion depth was reached, then the packets can be stored here as an unstructured byte stream. (If the caller so chooses, the content can be parsed later using the regular deserialization routines, since the content is just an OpenPGP message.)
Variants§
Unprocessed(Vec<u8>)
Unprocessed packet body.
The body has not been processed. This happens in the following cases:
-
The packet is a
Literal
packet. -
The packet is an
Unknown
packet, i.e. it contains data that we failed to process, say because we didn’t support the packet’s version. -
The packet is an encryption container (
SEIP
orAED
) and the body is encrypted.
Note: if some of a packet’s data is streamed, and the
PacketParser
is configured to buffer unread content, then
this is not the packet’s entire content; it is just the unread
content.
Processed(Vec<u8>)
Processed packed body.
The body has been processed, i.e. decompressed or decrypted, but not parsed into packets.
Note: if some of a packet’s data is streamed, and the
PacketParser
is configured to buffer unread content, then
this is not the packet’s entire content; it is just the unread
content.
Structured(Vec<Packet>)
Parsed packet body.
Used by container packets (such as the encryption and compression packets) to reference their immediate children. This results in a tree structure.
This is automatically populated when using the PacketPile
deserialization routines, e.g., PacketPile::from_file
. By
default, it is not automatically filled in by the
PacketParser
deserialization routines; this needs to be
done manually.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Body
impl RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnwindSafe for Body
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)