#[non_exhaustive]pub enum Error {
EmptyInput,
MissingFrom,
InvalidDate(String),
InvalidAddress(String),
MissingSender,
InvalidHeaderName(String),
InvalidMessageId(String),
HeaderLineTooLong(String),
ReservedHeaderName(String),
InvalidAttachment(String),
InvalidTraceHeader(String),
InvalidResentHeader(String),
}Expand description
Errors that can occur during email message parsing or building.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
EmptyInput
Empty input provided to the parser (RFC 5322 Section 3.5 — a valid message must contain at least header fields, so zero bytes is invalid).
MissingFrom
Missing required From header (RFC 5322 Section 3.6.2).
InvalidDate(String)
Date header could not be parsed per RFC 5322 Section 3.3.
InvalidAddress(String)
Syntactically invalid email address (RFC 5322 Section 3.4).
MissingSender
Missing Sender header when From has multiple addresses
(RFC 5322 Section 3.6.2).
RFC 5322: “If the from field contains more than one mailbox specification in the mailbox-list, then the sender field, containing the field value corresponding to the responsible agent of the message MUST be present in the message.”
InvalidHeaderName(String)
Invalid header field name (RFC 5322 Section 2.2).
The name is empty, contains non-ftext characters, or is otherwise
malformed per RFC 5322 Section 2.2 (field-name = 1*ftext).
InvalidMessageId(String)
Invalid message-ID (RFC 5322 Section 3.6.4).
The value is empty, missing the @ separator, contains prohibited
characters, or has empty id-left / id-right parts.
HeaderLineTooLong(String)
A header value contains a token or whitespace run that cannot be folded within the 998-octet line limit (RFC 5322 Sections 2.1.1, 2.2.3).
ReservedHeaderName(String)
An extra_headers entry uses a field name reserved for standard headers
managed by the builder (RFC 5322 Section 3.6).
InvalidAttachment(String)
An attachment violates MIME constraints — invalid content encoding, missing required headers, or prohibited bytes (RFC 2045/2046).
InvalidTraceHeader(String)
A trace header (Return-Path / Received) violates RFC 5322 Section 3.6.7 syntax or cardinality rules.
InvalidResentHeader(String)
A Resent-* header violates RFC 5322 Section 3.6.6 syntax, cardinality, or block-grouping rules.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()