Trait sequoia_openpgp::packet::prelude::Any[][src]

pub trait Any<T>: Sealed {
    fn downcast(self) -> Result<T, Packet>;
fn downcast_ref(&self) -> Option<&T>;
fn downcast_mut(&mut self) -> Option<&mut T>; }
Expand description

Convenient downcasting from Packets to Packet Bodies.

This trait offers functionality similar to std::any::Any, hence the name.

Sealed trait

This trait is sealed and cannot be implemented for types outside this crate. Therefore it can be extended in a non-breaking way.

Required methods

Attempts to downcast to T, returning the packet if it fails.

Examples
let p: Packet = Marker::default().into();
let m: Marker = p.downcast().unwrap();

Attempts to downcast to &T, returning None if it fails.

Examples
let p: Packet = Marker::default().into();
let m: &Marker = p.downcast_ref().unwrap();

Attempts to downcast to &mut T, returning None if it fails.

Examples
let mut p: Packet = Marker::default().into();
let m: &mut Marker = p.downcast_mut().unwrap();

Implementors