Skip to main content

Crate imap_rs

Crate imap_rs 

Source
Expand description

imap-rs: a modern, high-performance, security-first IMAP client for Rust.

This is the umbrella crate. It re-exports the three workspace crates and a handful of convenience entry points, so most users need only one dependency:

[dependencies]
imap-rs = "0.2"

§Quick start

use imap_rs::connect_tls;
use imap_rs::credentials::Password;

// TCP + TLS handshake (both with timeouts), then CAPABILITY inside TLS.
let session = connect_tls("imap.example.com", 993).await?;
// `login` only exists on a TLS session — enforced at compile time.
let auth = session.login("user", Password::new("pass")).await?;
let mut inbox = auth.select("INBOX").await?;
for msg in inbox.fetch("1:*", "BODY[]").await? {
    println!("seq={} uid={:?}", msg.seq, msg.uid);
}

§Highlights

  • Security-first: rustls-only TLS, zeroized credentials, #![forbid(unsafe_code)], and a fuzzed, bounds-checked parser.
  • Compile-time-correct sessions: illegal protocol transitions do not compile (see Session).
  • Zero-copy parser with a small dependency tree.

§Crate layout

The implementation is split across three crates, re-exported here:

Re-exports§

pub use imap_core as core;
pub use imap_client as client;
pub use imap_tls as tls;

Modules§

credentials
Secret credential wrappers (Password and OAuthToken) re-exported from imap_client::credentials.

Structs§

Session
Generic session enforcing compile-time state transitions.

Functions§

connect_starttls
Connect to an IMAP server in cleartext (port 143), advertise STARTTLS, upgrade the same TCP stream to TLS, and only then begin trusting the server’s capabilities.
connect_tls
Connect over TCP and immediately perform a TLS handshake (port 993).