Expand description
Core protocol types and traits for RusMES
This crate defines the fundamental data types shared across every component of the RusMES mail server. It is intentionally free of network I/O and heavy dependencies so that it can be compiled quickly and linked into all other crates.
§Key Features
- Validated address types —
MailAddress,Domain, andUsernameenforce RFC constraints at construction time and expose infallible accessors. - Mail state machine —
MailStatemodels the lifecycle of a mail item as it flows through the mailet processing pipeline (Root → Transport → LocalDelivery / Error / Ghost / Custom). - Mail envelope —
Mailwraps aMimeMessagewith SMTP envelope data (sender, recipients, remote IP/host), custom attributes for mailet communication, and a split operation for fan-out delivery. - MIME message —
MimeMessageprovides parsed header access and body handling for both in-memory (Small) and streaming (Large) messages, including multipart parsing, base64 / quoted-printable decoding, and Content-Type inspection. - Typed identifiers — UUID-backed
MailIdandMessageIdfor unambiguous tracking of mail items and messages throughout the system.
§Module Overview
| Module | Contents |
|---|---|
address | MailAddress, Domain, Username |
error | MailError, Result alias |
mail | Mail, MailId, MailState, AttributeValue |
message | MimeMessage, MessageId, HeaderMap, MessageBody |
mime | MIME parsing helpers, ContentType, MimePart |
§Brief Usage Example
use rusmes_proto::{Domain, MailAddress, Mail, MailState};
use rusmes_proto::message::{HeaderMap, MessageBody, MimeMessage};
use bytes::Bytes;
// Build a validated address
let domain = Domain::new("example.com").expect("valid domain");
let addr = MailAddress::new("alice", domain).expect("valid address");
assert_eq!(addr.to_string(), "alice@example.com");
// Create a mail envelope
let headers = HeaderMap::new();
let body = MessageBody::Small(Bytes::from("Hello, world!"));
let msg = MimeMessage::new(headers, body);
let mail = Mail::new(Some(addr), vec![], msg, None, None);
assert_eq!(mail.state, MailState::Root);§Relevant Standards
- Email address syntax: RFC 5321 §4.1.2, RFC 5322 §3.4
- MIME: RFC 2045, RFC 2046, RFC 2047
- Domain names: RFC 1035, RFC 5891 (IDNA)
Re-exports§
pub use address::Domain;pub use address::MailAddress;pub use address::Username;pub use error::MailError;pub use error::Result;pub use mail::AttributeValue;pub use mail::Mail;pub use mail::MailId;pub use mail::MailState;pub use message::HeaderMap;pub use message::MessageBody;pub use message::MessageId;pub use message::MimeMessage;pub use mime::ContentTransferEncoding;pub use mime::ContentType;pub use mime::MimePart;