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

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

Fields used by multiple packet types.


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.


impl Common[src]

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 Clone for Common[src]

impl Debug for Common[src]

impl Default for Common[src]

impl Eq for Common[src]

impl Hash for Common[src]

impl PartialEq<Common> for Common[src]

impl StructuralEq for Common[src]

impl StructuralPartialEq for Common[src]

Auto Trait Implementations

impl !RefUnwindSafe for Common

impl Send for Common

impl !Sync for Common

impl Unpin for Common

impl UnwindSafe for Common

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.