//! 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 std::vec;
use std::io;
use Result;
use Packet;
pub mod prelude;
pub mod ctb;
use self::ctb::PacketLengthType;
use buffered_reader::BufferedReader;
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 use self::signature::Signature;
mod one_pass_sig;
pub use self::one_pass_sig::OnePassSig;
pub mod key;
pub use self::key::Key;
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;
mod seip;
pub use self::seip::SEIP;
pub mod skesk;
mod pkesk;
pub use self::pkesk::PKESK;
mod mdc;
pub use self::mdc::MDC;
pub mod aed;
mod features;
pub use self::features::Features;
mod key_flags;
pub use self::key_flags::KeyFlags;
mod server_preferences;
pub use self::server_preferences::KeyServerPreferences;
// 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::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::SEIP(ref packet) => &packet.common,
&Packet::MDC(ref packet) => &packet.common,
&Packet::AED(AED::V1(ref packet)) => &packet.common,
}
}
}
impl<'a> DerefMut for Packet {
fn deref_mut(&mut self) -> &mut Common {
match self {
&mut Packet::Unknown(ref mut packet) => &mut packet.common,
&mut Packet::Signature(ref mut packet) => &mut packet.common,
&mut Packet::OnePassSig(ref mut packet) => &mut packet.common,
&mut Packet::PublicKey(ref mut packet) => &mut packet.common,
&mut Packet::PublicSubkey(ref mut packet) => &mut packet.common,
&mut Packet::SecretKey(ref mut packet) => &mut packet.common,
&mut Packet::SecretSubkey(ref mut packet) => &mut packet.common,