[][src]Struct sequoia_openpgp::packet::Common

pub struct Common {
    pub children: Option<Container>,
    pub body: Option<Vec<u8>>,
}

Fields used by multiple packet types.

Fields

children: Option<Container>

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.

body: Option<Vec<u8>>

Holds a packet's body.

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:

  • Packets like the UserID and Signature packets, don't actually have a body. These packets don't use this field.
  • One packet, the literal data packet, includes unstructured data. That data can be stored here.

  • 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 a 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.)

Note: if some of a packet's data is processed, and the PacketParser is configured to buffer unread content, then this is not the packet's entire content; it is just the unread content.

Methods

impl Common[src]

Important traits for PacketIter<'a>
pub fn descendants(&self) -> PacketIter[src]

Returns an iterator over all of the packet's descendants, in depth-first order.

pub fn body(&self) -> Option<&[u8]>[src]

Retrieves the packet's body.

Packets can store a sequence of bytes as body, e.g. if the maximum recursion level is reached while parsing a sequence of packets, the container's body is stored as is.

pub fn set_body(&mut self, data: Vec<u8>)[src]

Sets the packet's body.

Setting the body clears the old body, or any of the packet's descendants.

Trait Implementations

impl Eq for Common[src]

impl Default for Common[src]

impl PartialEq<Common> for Common[src]

impl Clone for Common[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Hash for Common[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for Common[src]

Auto Trait Implementations

impl Send for Common

impl !Sync for Common

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.