//! OpenPGP Message support.
//!
//! An OpenPGP message is a sequence of OpenPGP packets that
//! corresponds to an optionally signed, optionally encrypted,
//! optionally compressed literal data packet. The exact format of an
//! OpenPGP message is described in [Section 11.3 of RFC 4880].
//!
//! This module provides support for validating and working with
//! OpenPGP messages.
//!
//! [Section 11.3 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-11.3
use std::fmt;
use std::io;
use std::path::Path;
use failure;
use crate::Result;
use crate::Error;
use crate::Packet;
use crate::PacketPile;
use crate::Message;
use crate::packet::Literal;
use crate::packet::Tag;
use crate::parse::Parse;
mod lexer;
mod grammar;
use self::lexer::{Lexer, LexicalError};
pub use self::lexer::Token;
use lalrpop_util::ParseError;
use self::grammar::MessageParser;
/// Errors that MessageValidator::check may return.
#[derive(Debug, Clone)]
pub enum MessageParserError {
/// A parser error.
Parser(ParseError<usize, Token, LexicalError>),
/// An OpenPGP error.
OpenPGP(Error),
}
impl From<MessageParserError> for failure::Error {
fn from(err: MessageParserError) -> Self {
match err {
MessageParserError::Parser(p) => p.into(),
MessageParserError::OpenPGP(p) => p.into(),