Skip to main content

PacketParserResult

Enum PacketParserResult 

Source
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>

Source

pub fn is_eof(&self) -> bool

Returns true if the result is EOF.

Source

pub fn is_some(&self) -> bool

Returns true if the result is Some.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a> From<PacketParserResult<'a>> for CertParser<'a>

Source§

fn from(ppr: PacketParserResult<'a>) -> CertParser<'a> ⓘ

Initializes a CertParser from a PacketParser.

Source§

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,

Starts parsing an OpenPGP object stored in a BufferedReader object.

This function returns a PacketParser for the first packet in the stream.

Source§

fn from_reader<R>(reader: R) -> Result<T, Error>
where R: 'a + Read + Send + Sync,

Reads from the given reader. Read more
Source§

fn from_file<P>(path: P) -> Result<T, Error>
where P: AsRef<Path>,

Reads from the given file. Read more
Source§

fn from_bytes<D>(data: &'a D) -> Result<T, Error>
where D: AsRef<[u8]> + Send + Sync + ?Sized,

Reads from the given slice. Read more
Source§

impl TryFrom<PacketParserResult<'_>> for Cert

Source§

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§

type Error = Error

The type returned in the event of a conversion error.
Source§

impl<'a> TryFrom<PacketParserResult<'a>> for PacketPile

Source§

fn try_from(ppr: PacketParserResult<'a>) -> Result<PacketPile, Error>

Reads all the packets from a PacketParser, and turns them into a message.

Note: this assumes that ppr points to a top-level packet.

Source§

type Error = Error

The type returned in the event of a conversion error.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSync for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more