#[non_exhaustive]pub enum MessageIdParseError {
MissingBrackets,
ContainsWhitespace,
MissingLocal,
MissingDomain,
#[non_exhaustive] InvalidContent {
source: EmailAddressParseError,
},
ObsoleteIdLeftForm,
}Expand description
Reasons a string cannot be parsed as an RFC 5322 Message-ID.
use email_message::{MessageId, MessageIdParseError};
// Brackets are mandatory.
assert_eq!(
"abc@example.com".parse::<MessageId>().unwrap_err(),
MessageIdParseError::MissingBrackets,
);
// Local part validates against the addr-spec dot-atom grammar:
// a leading dot is illegal.
assert!(matches!(
"<.bad@example.com>".parse::<MessageId>().unwrap_err(),
MessageIdParseError::InvalidContent { .. },
));
// A well-formed Message-ID round-trips its bracketed form.
let parsed = "<good@example.com>".parse::<MessageId>()?;
assert_eq!(parsed.as_str(), "<good@example.com>");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
MissingBrackets
The value is not enclosed in angle brackets.
ContainsWhitespace
The value contains whitespace.
MissingLocal
The value has no local part before @.
MissingDomain
The value has no domain after @.
#[non_exhaustive]InvalidContent
The local part or domain violates the supported addr-spec grammar.
Fields
This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§
source: EmailAddressParseErrorThe underlying addr-spec validation error.
ObsoleteIdLeftForm
The id-left uses the unsupported obsolete quoted-string form.
Trait Implementations§
Source§impl Debug for MessageIdParseError
impl Debug for MessageIdParseError
Source§impl Display for MessageIdParseError
impl Display for MessageIdParseError
impl Eq for MessageIdParseError
Source§impl Error for MessageIdParseError
impl Error for MessageIdParseError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for MessageIdParseError
impl RefUnwindSafe for MessageIdParseError
impl Send for MessageIdParseError
impl Sync for MessageIdParseError
impl Unpin for MessageIdParseError
impl UnsafeUnpin for MessageIdParseError
impl UnwindSafe for MessageIdParseError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more