Skip to main content

daaki_message/
error.rs

1//! Typed error enum for email message parsing and building.
2//!
3//! # References
4//! - RFC 5322 (Internet Message Format)
5//! - RFC 2045–2047 (MIME)
6
7/// Errors that can occur during email message parsing or building.
8#[derive(Debug, thiserror::Error)]
9pub enum Error {
10    /// Empty input provided to the parser.
11    #[error("empty input: no message bytes provided")]
12    EmptyInput,
13
14    /// Missing required `From` header (RFC 5322 Section 3.6.2).
15    #[error("missing required From header (RFC 5322 Section 3.6.2)")]
16    MissingFrom,
17
18    /// Date header could not be parsed per RFC 5322 Section 3.3.
19    #[error("invalid date: {0}")]
20    InvalidDate(String),
21
22    /// Syntactically invalid email address (RFC 5322 Section 3.4).
23    #[error("invalid email address: {0}")]
24    InvalidAddress(String),
25
26    /// Error during message building.
27    #[error("build error: {0}")]
28    Build(String),
29}