[][src]Struct sequoia_openpgp::parse::PacketParserBuilder

pub struct PacketParserBuilder<'a> { /* fields omitted */ }

A builder for configuring a PacketParser.

Since the default settings are usually appropriate, this mechanism will only be needed in exceptional circumstances. Instead use, for instance, PacketParser::from_file or PacketParser::from_reader to start parsing an OpenPGP message.

Methods

impl<'a> PacketParserBuilder<'a>[src]

pub fn into_packet_pile_parser(self) -> Result<PacketPileParser<'a>> where
    Self: 'a, 
[src]

Finishes configuring the PacketParser and returns a PacketPileParser.

impl<'a> PacketParserBuilder<'a>[src]

pub fn max_recursion_depth(self, value: u8) -> Self[src]

Sets the maximum recursion depth.

Setting this to 0 means that the PacketParser will never recurse; it will only parse the top-level packets.

This is a u8, because recursing more than 255 times makes no sense. The default is MAX_RECURSION_DEPTH. (GnuPG defaults to a maximum recursion depth of 32.)

pub fn buffer_unread_content(self) -> Self[src]

Causes PacketParser::finish() to buffer any unread content.

The unread content is stored in the Packet::content Option.

pub fn drop_unread_content(self) -> Self[src]

Causes PacketParser::finish() to drop any unread content. This is the default.

pub fn map(self, enable: bool) -> Self[src]

Controls mapping.

Note that enabling mapping buffers all the data.

pub fn dearmor(self, mode: Dearmor) -> Self[src]

How to treat the input stream.

pub fn finalize(self) -> Result<PacketParserResult<'a>> where
    Self: 'a, 
[src]

Finishes configuring the PacketParser and returns an Option<PacketParser>.

Examples

let ppr = PacketParserBuilder::from_bytes(message_data)?.finalize()?;

impl<'a> PacketParserBuilder<'a>[src]

pub fn into_packet_pile(self) -> Result<PacketPile>[src]

Finishes configuring the PacketParser and returns a fully parsed message.

Note: calling this function does not change the default settings PacketParserSettings. Thus, by default, the content of packets will not be buffered.

Note: to avoid denial of service attacks, the PacketParser interface should be preferred unless the size of the message is known to fit in memory.

Examples

let message = PacketParserBuilder::from_bytes(message_data)?
    .buffer_unread_content()
    .into_packet_pile()?;

Trait Implementations

impl<'a> Parse<'a, PacketParserBuilder<'a>> for PacketParserBuilder<'a>[src]

fn from_reader<R: Read + 'a>(reader: R) -> Result<Self>[src]

Creates a PacketParserBuilder for an OpenPGP message stored in a std::io::Read object.

fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>[src]

Creates a PacketParserBuilder for an OpenPGP message stored in the file named path.

fn from_bytes(bytes: &'a [u8]) -> Result<PacketParserBuilder>[src]

Creates a PacketParserBuilder for an OpenPGP message stored in the specified buffer.

Auto Trait Implementations

impl<'a> !Send for PacketParserBuilder<'a>

impl<'a> !Sync for PacketParserBuilder<'a>

Blanket Implementations

impl<T> From for T[src]

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

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.