Skip to main content

Crate rusmes_proto

Crate rusmes_proto 

Source
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 typesMailAddress, Domain, and Username enforce RFC constraints at construction time and expose infallible accessors.
  • Mail state machineMailState models the lifecycle of a mail item as it flows through the mailet processing pipeline (Root → Transport → LocalDelivery / Error / Ghost / Custom).
  • Mail envelopeMail wraps a MimeMessage with SMTP envelope data (sender, recipients, remote IP/host), custom attributes for mailet communication, and a split operation for fan-out delivery.
  • MIME messageMimeMessage provides 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 MailId and MessageId for unambiguous tracking of mail items and messages throughout the system.

§Module Overview

ModuleContents
addressMailAddress, Domain, Username
errorMailError, Result alias
mailMail, MailId, MailState, AttributeValue
messageMimeMessage, MessageId, HeaderMap, MessageBody
mimeMIME 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

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;

Modules§

address
Email address types
error
Error types for RusMES protocol operations
mail
Mail envelope and state machine
message
MIME message types
mime
MIME parsing support for RFC 5322 and RFC 2045