//! Packet-related types.
//!
//! See [Section 4 of RFC 4880] for more details.
//!
//! [Section 4 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-4
use std::fmt;
use std::ops::{Deref, DerefMut};
use std::slice;
use crate::Error;
use crate::Result;
use crate::Packet;
#[macro_use]
mod container;
pub(crate) use container::Container;
pub mod prelude;
use crate::crypto::KeyPair;
mod tag;
pub use self::tag::Tag;
pub mod header;
pub use self::header::Header;
mod unknown;
pub use self::unknown::Unknown;
pub mod signature;
pub mod one_pass_sig;
pub mod key;
mod marker;
pub use self::marker::Marker;
mod trust;
pub use self::trust::Trust;
mod userid;
pub use self::userid::UserID;
pub mod user_attribute;
pub use self::user_attribute::UserAttribute;
mod literal;
pub use self::literal::Literal;
mod compressed_data;
pub use self::compressed_data::CompressedData;
pub mod seip;
pub mod skesk;
pub mod pkesk;
mod mdc;
pub use self::mdc::MDC;
pub mod aed;
// Allow transparent access of common fields.
impl<'a> Deref for Packet {
type Target = Common;
fn deref(&self) -> &Self::Target {
match self {
&Packet::Unknown(ref packet) => &packet.common,
&Packet::Signature(ref packet) => &packet.common,
&Packet::OnePassSig(ref packet) => &packet.common,
&Packet::PublicKey(ref packet) => &packet.common,
&Packet::PublicSubkey(ref packet) => &packet.common,
&Packet::SecretKey(ref packet) => &packet.common,
&Packet::SecretSubkey(ref packet) => &packet.common,
&Packet::Marker(ref packet) => &packet.common,
&Packet::Trust(ref packet) => &packet.common,
&Packet::UserID(ref packet) => &packet.common,
&Packet::UserAttribute(ref packet) => &packet.common,
&Packet::Literal(ref packet) => &packet.common,
&Packet::CompressedData(ref packet) => &packet.common,
&Packet::PKESK(ref packet) => &packet.common,
&Packet::SKESK(SKESK::V4(ref packet)) => &packet.common,
&Packet::SKESK(SKESK::V5(ref packet)) => &packet.skesk4.common,
Packet::SKESK(SKESK::__Nonexhaustive) => unreachable!(),
&Packet::SEIP(ref packet) => &packet.common,
&Packet::MDC(ref packet) => &packet.common,
&Packet::AED(ref packet) => &packet.common,
Packet::__Nonexhaustive => unreachable!(),
}
}
}
impl<'a> DerefMut for Packet {
fn deref_mut(&mut self) -> &mut Common {
match self {
&mut Packet::Unknown(ref