pub enum PacketParserResult<'a> {
Some(PacketParser<'a>),
EOF(PacketParserEOF<'a>),
}Expand description
The result of parsing a packet.
This type is returned by PacketParser::next,
PacketParser::recurse, PacketParserBuilder::build, and the
implementation of PacketParser’s Parse trait. The result
is either Some(PacketParser), indicating successful parsing of a
packet, or EOF(PacketParserEOF) if the end of the input stream
has been reached.
Variants§
Some(PacketParser<'a>)
A PacketParser for the next packet.
EOF(PacketParserEOF<'a>)
Information about a fully parsed packet sequence.
Implementations§
Source§impl<'a> PacketParserResult<'a>
impl<'a> PacketParserResult<'a>
Sourcepub fn expect(self, msg: &str) -> PacketParser<'a> ⓘ
pub fn expect(self, msg: &str) -> PacketParser<'a> ⓘ
Unwraps a result, yielding the content of an Some.
§Panics
Panics if the value is an EOF, with a panic message
including the passed message, and the information in the
PacketParserEOF object.
Sourcepub fn unwrap(self) -> PacketParser<'a> ⓘ
pub fn unwrap(self) -> PacketParser<'a> ⓘ
Unwraps a result, yielding the content of an Some.
§Panics
Panics if the value is an EOF, with a panic message
including the information in the PacketParserEOF object.
Sourcepub fn as_ref(&self) -> Result<&PacketParser<'a>, &PacketParserEOF<'a>>
pub fn as_ref(&self) -> Result<&PacketParser<'a>, &PacketParserEOF<'a>>
Converts from PacketParserResult to Result<&PacketParser, &PacketParserEOF>.
Produces a new Result, containing references into the
original PacketParserResult, leaving the original in place.
Sourcepub fn as_mut(
&mut self,
) -> Result<&mut PacketParser<'a>, &mut PacketParserEOF<'a>>
pub fn as_mut( &mut self, ) -> Result<&mut PacketParser<'a>, &mut PacketParserEOF<'a>>
Converts from PacketParserResult to Result<&mut PacketParser, &mut PacketParserEOF>.
Produces a new Result, containing mutable references into the
original PacketParserResult, leaving the original in place.
Sourcepub fn take(&mut self) -> PacketParserResult<'a>
pub fn take(&mut self) -> PacketParserResult<'a>
Takes the value out of the PacketParserResult, leaving a
EOF in its place.
The EOF left in place carries a PacketParserEOF with
default values.
Sourcepub fn map<U, F>(self, f: F) -> Result<U, PacketParserEOF<'a>>where
F: FnOnce(PacketParser<'a>) -> U,
pub fn map<U, F>(self, f: F) -> Result<U, PacketParserEOF<'a>>where
F: FnOnce(PacketParser<'a>) -> U,
Maps a PacketParserResult to Result<PacketParser, PacketParserEOF> by applying a function to a contained Some
value, leaving an EOF value untouched.
Trait Implementations§
Source§impl<'a> Debug for PacketParserResult<'a>
impl<'a> Debug for PacketParserResult<'a>
Source§impl<'a> From<PacketParserResult<'a>> for CertParser<'a>
impl<'a> From<PacketParserResult<'a>> for CertParser<'a>
Source§fn from(ppr: PacketParserResult<'a>) -> CertParser<'a> ⓘ
fn from(ppr: PacketParserResult<'a>) -> CertParser<'a> ⓘ
Initializes a CertParser from a PacketParser.
Source§impl<'a> Parse<'a, PacketParserResult<'a>> for PacketParser<'a>
impl<'a> Parse<'a, PacketParserResult<'a>> for PacketParser<'a>
Source§fn from_buffered_reader<R>(reader: R) -> Result<PacketParserResult<'a>, Error>where
R: BufferedReader<Cookie> + 'a,
fn from_buffered_reader<R>(reader: R) -> Result<PacketParserResult<'a>, Error>where
R: BufferedReader<Cookie> + 'a,
Starts parsing an OpenPGP object stored in a BufferedReader object.
This function returns a PacketParser for the first packet in
the stream.
Source§impl TryFrom<PacketParserResult<'_>> for Cert
impl TryFrom<PacketParserResult<'_>> for Cert
Source§fn try_from(ppr: PacketParserResult<'_>) -> Result<Cert, Error>
fn try_from(ppr: PacketParserResult<'_>) -> Result<Cert, Error>
Returns the Cert found in the packet stream.
If the sequence contains multiple certificates (i.e., it is a
keyring), or the certificate is followed by an invalid packet
this function will fail. To parse keyrings, use
CertParser instead of this function.
Source§impl<'a> TryFrom<PacketParserResult<'a>> for PacketPile
impl<'a> TryFrom<PacketParserResult<'a>> for PacketPile
Auto Trait Implementations§
impl<'a> !Freeze for PacketParserResult<'a>
impl<'a> !RefUnwindSafe for PacketParserResult<'a>
impl<'a> !UnwindSafe for PacketParserResult<'a>
impl<'a> Send for PacketParserResult<'a>
impl<'a> Sync for PacketParserResult<'a>
impl<'a> Unpin for PacketParserResult<'a>
impl<'a> UnsafeUnpin for PacketParserResult<'a>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more