Skip to main content

io_smtp/rfc5321/types/
mailbox.rs

1//! SMTP mailbox (RFC 5321 ยง4.1.2).
2//!
3//! A full email address: a local part, an at sign and a domain or
4//! address literal.
5
6use core::fmt;
7
8use bounded_static_derive::ToStatic;
9
10use crate::rfc5321::types::{ehlo_domain::SmtpEhloDomain, local_part::SmtpLocalPart};
11
12/// A full email address: local-part@domain.
13#[derive(Debug, Clone, PartialEq, Eq, Hash, ToStatic)]
14pub struct SmtpMailbox<'a> {
15    /// The local part (before @)
16    pub local_part: SmtpLocalPart<'a>,
17    /// The domain (after @)
18    pub domain: SmtpEhloDomain<'a>,
19}
20
21impl fmt::Display for SmtpMailbox<'_> {
22    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23        write!(f, "{}@{}", self.local_part, self.domain)
24    }
25}