Skip to main content

Crate mailrs_imap_proto

Crate mailrs_imap_proto 

Source
Expand description

IMAP protocol parser and response formatter.

mailrs-imap-proto implements the wire-format pieces of RFC 3501 (IMAP4rev1) — tagged command parsing, sequence-set arithmetic, and response line formatting. It does no I/O and owns no state; it’s the protocol layer underneath an IMAP server you write yourself.

This crate underpins the IMAP server in mailrs, a Rust mail server, and is published independently so other Rust projects can reuse the parsing layer.

§Quick start

use mailrs_imap_proto::{parse_command, ImapCommand, format_capability};

// parse a wire-format tagged command line
let parsed = parse_command("a001 CAPABILITY").unwrap();
assert_eq!(parsed.tag, "a001");
assert_eq!(parsed.command, ImapCommand::Capability);

// format the matching response
let resp = format_capability(&["IMAP4rev1", "IDLE", "AUTH=PLAIN"]);
assert_eq!(resp, "* CAPABILITY IMAP4rev1 IDLE AUTH=PLAIN\r\n");

§What this crate does

§What this crate does NOT do

  • No I/O. No TCP, no TLS, no async runtime, no connection management.
  • No mailbox storage or message indexing.
  • No session state machine. Unlike mailrs-smtp-proto, IMAP’s per-connection state (selected mailbox, capability negotiation, pending IDLE) is owned by the caller — this crate just gives typed commands and formatted replies.

Re-exports§

pub use command::ImapCommand;
pub use command::ParseError;
pub use command::SearchKey;
pub use command::TaggedCommand;
pub use command::parse_command;
pub use command::parse_search_criteria;
pub use sequence::SequenceSet;
pub use sequence::parse_sequence_set;
pub use sequence::sequence_set_to_uids;
pub use response::*;

Modules§

command
IMAP4rev1 command parser + ImapCommand AST.
response
IMAP wire-format response formatters.
sequence
Sequence-set parser + expansion (1:10,12,*).