[−][src]Struct sequoia_openpgp::parse::PacketParserBuilder
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.
Implementations
impl<'a> PacketParserBuilder<'a>
[src]
pub fn into_packet_pile_parser(self) -> Result<PacketPileParser<'a>> where
Self: 'a,
[src]
Self: 'a,
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 max_packet_size(self, value: u32) -> Self
[src]
Sets the maximum size of non-container packets.
Packets that exceed this limit will be returned as
Packet::Unknown
, with the error set to
Error::PacketTooLarge
.
This limit applies to any packet type that is not a container packet, i.e. any packet that is not a literal data packet, a compressed data packet, a symmetrically encrypted data packet, or an AEAD encrypted data packet.
The default is 1 MiB.
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]
Self: 'a,
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<D: AsRef<[u8]> + ?Sized>(
data: &'a D
) -> Result<PacketParserBuilder<'a>>
[src]
data: &'a D
) -> Result<PacketParserBuilder<'a>>
Creates a PacketParserBuilder
for an OpenPGP message stored
in the specified buffer.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for PacketParserBuilder<'a>
impl<'a> !Send for PacketParserBuilder<'a>
impl<'a> !Sync for PacketParserBuilder<'a>
impl<'a> Unpin for PacketParserBuilder<'a>
impl<'a> !UnwindSafe for PacketParserBuilder<'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>,