IMAP MailReader backend (list/fetch only — IMAP is structurally read-only, SMTP is the separate send side)
| Tier | infrastructure |
| Role | unclassified (baselined) |
| Path | crates/infrastructure/imap |
| Edition | 2021 |
| Targets | infrastructure_imap |
| Public items | 0 across 0 modules |
| Tests | 23 |
What it is for
# infrastructure-imap
IMAP backend implementing foundation_mail_message::MailReader only.
IMAP is structurally read-only in this design — sending mail is the separate infrastructure-smtp crate (sprint 3.45 crate 4). ImapReader therefore has no send method at all, not a stubbed/panicking one (AC-capability-boundary, sprint 3.45 doc).
Security (Gate 1.5.6)
IMAP reads attacker-reachable remote content — any message sitting in a real mailbox, from any sender. Every fetch():
- checks the server-reported
RFC822.SIZEagainst
config::ImapConfig::max_message_bytes before issuing the full-body fetch (size_guard.rs), so an oversized message is rejected without ever downloading its body/attachments;
- re-checks the bytes actually received as a second, defense-in-depth
bound, in case a server misreports its own size;
- runs under
config.connect_timeout(TCP connect + TLS + auth) and
config.io_timeout (each subsequent IMAP command), both wall-clock bounds via tokio::time::timeout on real tokio::net::TcpStream I/O — not the blocking std::net::TcpStream + AllowStdIo pattern the wrapped source used, which cannot honor a timeout mid-read since it blocks the executor thread instead of yielding at an await point.
Credentials (config::ImapAuth) are held only in ImapConfig and never logged; error messages built in backend.rs interpolate protocol text (IMAP NO/BAD responses, transport errors), never the password/token themselves.
Trait fit (OQ4-adjacent finding)
See message_id.rs's doc comment for the one real signature-fit issue: MailReader::fetch(&self, id: &str) has no mailbox parameter, but IMAP UIDs are only unique within one mailbox. Resolved entirely on this side (composite opaque id), no change to crate 1's trait needed.
Capabilities
No public items.
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
No public modules: the crate root is its whole surface.
Public surface
No public items.
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
ImapReader | backend::ImapReader |
rfc822_to_email | parse::rfc822_to_email |
{ImapAuth,ImapConfig} | config::{ImapAuth,ImapConfig} |
Boundary
Reaches into foundation.
Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 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) | infrastructure |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/infrastructure/imap |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_infrastructure["infrastructure"] --> n_foundation["foundation"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-mail-message` | foundation | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-imap | ^0.10 | runtime-tokio | no | always |
async-native-tls | ^0.5 | runtime-tokio | no | always |
async-trait | ^0.1 | — | no | always |
base64 | ^0.22 | — | no | always |
chrono | ^0.4 | serde | no | always |
futures | ^0.3 | — | no | always |
mailparse | ^0.15 | — | no | always |
thiserror | ^2 | — | no | always |
tokio | ^1 | full, net, time | no | always |
tracing | ^0.1 | — | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio-test | ^0.4 | — | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_tools_mail_manager["tools-mail-manager"] -->|uses| SELF SELF["infrastructure-imap"] SELF -->|runtime| n_foundation_mail_message["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
| Kind | Name | Source |
|---|---|---|
| lib | infrastructure_imap | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | yes |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none 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.
Related capabilities
1 workspace crate depends on this one: tools-mail-manager.
Verification
| Kind | Count |
|---|---|
| Unit tests | 23 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
What the tests establish, by name:
map_imap_error_never_leaks_the_backend_error_type—src/backend.rsbuilder_methods_override_defaults—src/config.rsnew_applies_sane_defaults—src/config.rsrejects_a_cursor_from_a_different_backend_shape—src/cursor.rsrejects_empty_string—src/cursor.rsrejects_non_numeric_fields—src/cursor.rsround_trips_through_encode_decode—src/cursor.rsdistinguishes_the_same_uid_in_different_mailboxes—src/message_id.rsrejects_a_non_numeric_uid—src/message_id.rsrejects_an_id_with_no_delimiter—src/message_id.rsround_trips_a_hierarchical_mailbox_name—src/message_id.rsround_trips_a_simple_mailbox—src/message_id.rscaptures_message_id_and_bulk_mail_headers—src/parse.rsmissing_optional_headers_default_sanely—src/parse.rsparses_headers_and_plain_body_from_a_simple_message—src/parse.rsrejects_unparseable_bytes—src/parse.rswalks_multipart_into_text_html_and_attachment_parts—src/parse.rsaccepts_a_message_exactly_at_the_cap—src/size_guard.rsaccepts_a_message_within_the_cap—src/size_guard.rsrejects_a_message_over_the_cap_without_needing_the_body—src/size_guard.rsrejects_an_unreported_size_rather_than_assuming_small—src/size_guard.rsauthenticator_replays_the_same_response_regardless_of_challenge—src/xoauth2.rsencodes_user_and_token_as_base64_sasl_string—src/xoauth2.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 0 | 0 |
Public modules with a //! block | 0 | 0 |
Metrics
| Metric | Value |
|---|---|
| Rust source files | 8 |
| Source lines | 1062 |
| Code lines | 721 |
| Public API items | 0 |
| Public modules | 0 |
| Tests | 23 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 11 |
| Workspace reverse dependencies | 1 |
pie showData
title Rust source composition
"Code" : 721
"Blank or comment" : 341
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.