Expand description
daaki IMAP client library.
An IMAP4rev1 (RFC 3501) and IMAP4rev2 (RFC 9051) async client
built on tokio and rustls. Single crate — parser, types, and connection
in one place.
§Architecture
§Driver task
ImapConnection is a lightweight handle — it holds an
mpsc::Sender<DriverCommand> and a watch::Receiver for state
snapshots. A dedicated tokio task (the driver) owns the TCP/TLS
stream exclusively. All public methods take &self, submit commands
over the channel, and await a result via a oneshot. Dropping a
future mid-flight cannot corrupt the stream because no caller-side
future has access to it — the driver completes the in-flight command
and only the result is abandoned. This makes tokio::select! and
tokio::time::timeout safe to use around any operation.
§Consumer trait
Each IMAP command is executed by a Consumer
implementation. The driver feeds the consumer pre-classified responses
via on_response, then calls finalize when the tagged response
arrives. Consumers never make routing decisions — they only accumulate
data they are given. Commands that expect + continuations (e.g.
AUTHENTICATE) use the separate ContinuationConsumer trait with an
additional on_continuation method.
§Classification truth table
The function classify is the
single source of truth for whether an untagged response belongs to
the current command’s result or to the asynchronous event queue.
Every row cites the RFC section that defines the routing rule.
The dispatcher calls classify before each response and routes
mechanically — consumers have no routing decision to make.
§Typed event queue
Asynchronous server notifications — ALERTs, EXISTS/EXPUNGE changes,
NOTIFY data, BYE — arrive as TypedEvents. Poll them with
drain_events (non-blocking) or
next_event (with timeout). The
driver publishes events via a non-blocking DriverEventSink that
can never suspend the driver’s select loop.
§Wire reader and protocol state
All wire reads flow through a private WireReader in mod wire,
which is visible only within the connection module. All protocol
state mutations flow through
ProtocolState::apply_side_effects in mod state — the primary
mutator. The state module’s fields are pub(self), so direct
field assignment from outside mod state is a compile error.
§MailboxName
Every mailbox name in every public type is MailboxName — a
validated, decoded UTF-8 newtype with no From<String> impl. The
only constructors are new (public, validating) and from_decoded
(pub(crate), for already-parsed wire data in the codec). The
compiler refuses to smuggle wire-form bytes through any public type.
Re-exports§
pub use error::Error;pub use types::AclEntry;pub use types::AppendMessage;pub use types::BinarySection;pub use types::BodySection;pub use types::BodyStructure;pub use types::Capability;pub use types::ContentDisposition;pub use types::ContinuationRequest;pub use types::CopyResult;pub use types::Envelope;pub use types::EnvelopeAddress;pub use types::EsearchResponse;pub use types::ExpungeResult;pub use types::FetchAttr;pub use types::FetchResponse;pub use types::Flag;pub use types::GreetingResponse;pub use types::GreetingStatus;pub use types::ImapAtom;pub use types::ListRightsResponse;pub use types::MailboxAttribute;pub use types::MailboxFilter;pub use types::MailboxInfo;pub use types::MailboxName;pub use types::MetadataEntry;pub use types::MetadataResult;pub use types::MoveResult;pub use types::NamespaceDescriptor;pub use types::NamespaceResponse;pub use types::NotifyEvent;pub use types::NotifyEventGroup;pub use types::NotifySetParams;pub use types::ObjectId;pub use types::QresyncParams;pub use types::QuotaResource;pub use types::QuotaRootResponse;pub use types::Response;pub use types::ResponseCode;pub use types::SearchCriteria;pub use types::SelectOptions;pub use types::SelectedMailbox;pub use types::SequenceSet;pub use types::SpecialUse;pub use types::StatusItem;pub use types::StatusKind;pub use types::StatusResult;pub use types::StoreOperation;pub use types::StoreResult;pub use types::TaggedResponse;pub use types::ThreadNode;pub use types::UidRange;pub use types::UntaggedResponse;pub use types::UntaggedStatus;
Modules§
Structs§
- Address
- Re-export the canonical
Addresstype fromdaaki-messageso consumers can use a singleAddresstype across the IMAP, SMTP, and message crates without manual field-by-field conversion. An email address with optional display name. - Imap
Connection - An IMAP client connection (RFC 3501 Section 2 / RFC 9051 Section 2).
- Search
Result - Result of a SEARCH or UID SEARCH command.
- TcpKeepalive
- TCP keepalive configuration for the underlying socket.
- Validation
Error - Error returned when constructing a validated protocol type from an invalid string.
Enums§
- Idle
Event - Event received during an IDLE session (RFC 2177).
- Session
State - IMAP session state (RFC 3501 Section 3 / RFC 9051 Section 3).
- TlsMode
- TLS mode for the initial connection (RFC 8314).
- Typed
Event - Asynchronously delivered server data.
Type Aliases§
- Result
- Result type alias for IMAP operations.