foundation capa

foundation-mail-message

Provider-agnostic mail message types and MailReader/MailSender capability traits

Provider-agnostic mail message types and MailReader/MailSender capability traits

Tierfoundation
Roleunclassified (baselined)
Pathcrates/foundation/mail-message
Edition2021
Targetsfoundation_mail_message
Public items20 across 5 modules
Tests25

What it is for

# foundation-mail-message

Provider-agnostic mail message types and capability traits.

See README.md for the full design rationale (OQ1-OQ3 resolutions).

Capabilities

address (other)

Shared From-style address parsing: email/display-name extraction, root-domain

Item
fn extract_email_address(raw : & str) -> Option <String>
fn extract_display_name(raw : & str) -> Option <String>
fn extract_root_domain(domain : & str) -> String
fn is_noreply_local_part(local_part : & str) -> bool
fn is_machine_sender_local_part(local_part : & str) -> bool

MailError

Mail operation errors.

Item
pub enum MailError

MailReader

MailReader — list/fetch capability trait.

Item
pub trait MailReader

MailSender

MailSender — send capability trait.

Item
pub trait MailSender

SendReceipt

MailSender — send capability trait.

Item
pub struct SendReceipt

Attachment

Provider-agnostic mail message types.

Item
pub struct Attachment

Cursor

Provider-agnostic mail message types.

Item
pub struct Cursor
Cursor :: fn new(token : impl Into <String>) -> Self
Cursor :: fn as_str(& self) -> & str

Email

Provider-agnostic mail message types.

Item
pub struct Email
Email :: fn body_text(& self) -> Option <& str>
Email :: fn body_html(& self) -> Option <& str>
Email :: fn attachments(& self) -> Vec <& Attachment>

ListPage

Provider-agnostic mail message types.

Item
pub struct ListPage

MessageId

Provider-agnostic mail message types.

Item
pub struct MessageId

MessagePart

Provider-agnostic mail message types.

Item
pub enum MessagePart

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

foundation_mail_message

flowchart TD
  n_foundation_mail_message["foundation_mail_message"]
  n_foundation_mail_message --> n_address["address"]
  n_foundation_mail_message --> n_error["error"]
  n_foundation_mail_message --> n_reader["reader"]
  n_foundation_mail_message --> n_sender["sender"]
  n_foundation_mail_message --> n_types["types"]

Public surface

`address`

ItemWhat it is
fn extract_email_address(raw : & str) -> Option <String>Extract the email address embedded in a raw From-style header value ("Name" <email@domain>, bare email@domain, or a quoted-name variant)
fn extract_display_name(raw : & str) -> Option <String>Extract the display name from "Name" <email> / Name <email>, if present.
fn extract_root_domain(domain : & str) -> StringThe registrable root domain: the last two labels of domain (e.g
fn is_noreply_local_part(local_part : & str) -> boolTrue for the closed set of conventional noreply local parts (noreply, no-reply, no_reply, donotreply, do-not-reply, do_not_reply) — exact match only, not a prefix check.
fn is_machine_sender_local_part(local_part : & str) -> boolTrue for is_noreply_local_part plus a broader set of automated-sender local parts (notifications, alerts, billing, mailer-daemon, ...), matched as an exact local part or a {pattern}-/{pattern}+ prefix (so alerts-prod@ and alerts+2@ both match alerts).

`error`

ItemWhat it is
pub enum MailErrorErrors that can occur during MailReader/MailSender operations

`reader`

ItemWhat it is
pub trait MailReaderCapability trait for backends that can list and fetch mail

`sender`

ItemWhat it is
pub struct SendReceiptThe result of a successful MailSender::send call.
pub trait MailSenderCapability trait for backends that can send mail

`types`

ItemWhat it is
pub enum MessagePartA single content piece of a message: one of its text/HTML bodies, or one attachment
pub struct AttachmentA file attached to (or embedded in) a message.
pub struct EmailA provider-agnostic mail message — the input to MailSender::send and the output of MailReader::fetch
Email :: fn body_text(& self) -> Option <& str>The first text/plain part, if any.
Email :: fn body_html(& self) -> Option <& str>The first text/html part, if any.
Email :: fn attachments(& self) -> Vec <& Attachment>All attachment parts, in order.
pub struct MessageIdA bare message identifier returned by MailReader::list (OQ1)
pub struct CursorAn opaque, backend-issued pagination cursor (OQ2)
Cursor :: fn new(token : impl Into <String>) -> SelfWrap a backend-issued token
Cursor :: fn as_str(& self) -> & strThe raw token, to hand back to the same backend on the next call.
pub struct ListPageOne page of MessageIds from MailReader::list.

Re-exports. Exported here, defined elsewhere.

ExportDefined in
MailErrorerror::MailError
MailReaderreader::MailReader
{Attachment,Cursor,Email,ListPage,MessageId,MessagePart}types::{Attachment,Cursor,Email,ListPage,MessageId,MessagePart}
{MailSender,SendReceipt}sender::{MailSender,SendReceipt}
{extract_display_name,extract_email_address,extract_root_domain,is_machine_sender_local_part,is_noreply_local_part,}address::{extract_display_name,extract_email_address,extract_root_domain,is_machine_sender_local_part,is_noreply_local_part,}

Boundary

Depends on no other workspace tier.

Shares tier foundation with 27 other crates: foundation-audit-log, foundation-basemodels, foundation-bounded-io, foundation-conversation-closure, foundation-crypto-sign, foundation-decisioning, foundation-encounter-vocabulary, foundation-fs-metadata, … (27 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)foundation
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/foundation/mail-message
Vocabulary in force (lexicon)current

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
chrono^0.4serdenoalways
serde^1derivenoalways
serde_json^1noalways
thiserror^2noalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio^1fullnoalways
tokio-test^0.4noalways

Build. None.

Depended on by. 9 workspace crates.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_domain_sender_reputation["domain-sender-reputation"] -->|uses| SELF
  n_foundation_refresh_policy["foundation-refresh-policy"] -->|uses| SELF
  n_infrastructure_adapters_google_gmail["infrastructure-adapters-google-gmail"] -->|uses| SELF
  n_infrastructure_imap["infrastructure-imap"] -->|uses| SELF
  n_infrastructure_mail_extract["infrastructure-mail-extract"] -->|uses| SELF
  n_infrastructure_mail_headers["infrastructure-mail-headers"] -->|uses| SELF
  n_infrastructure_smtp["infrastructure-smtp"] -->|uses| SELF
  n_operations_mail_sync["operations-mail-sync"] -->|uses| SELF
  n_tools_mail_manager["tools-mail-manager"] -->|uses| SELF
  SELF["foundation-mail-message"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libfoundation_mail_message`src/lib.rs`

Error model

Error typeNamed by
MailErrordeclared, no public signature returns it

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

9 workspace crates depend on this one: domain-sender-reputation, foundation-refresh-policy, infrastructure-adapters-google-gmail, infrastructure-imap, infrastructure-mail-extract, infrastructure-mail-headers, infrastructure-smtp, operations-mail-sync, tools-mail-manager.

Verification

KindCount
Unit tests25
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
address5010
error105
reader106
sender2010
types6027

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc2020
Public modules with a //! block55
pie showData
    title Public items with rustdoc
    "Documented" : 20
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files6
Source lines1069
Code lines718
Public API items20
Public modules5
Tests25
Examples0
Cargo features0
Direct runtime dependencies5
Workspace reverse dependencies9
pie showData
    title Public API by kind
    "enum" : 2
    "function" : 5
    "method" : 5
    "struct" : 6
    "trait" : 2
pie showData
    title Rust source composition
    "Code" : 718
    "Blank or comment" : 351

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las foundation · Manual