Skip to content

calternal_imap::session

Execute shared IMAP commands on an authenticated message store (#428/#486, DESIGN §§9, 53). The selected sequence view stays stable until refresh; UID ranges are tested against actual rows, never expanded into attacker-sized vectors. This module is transport-independent and never logs command bytes.

Source: crates/calternal-imap/src/session.rs

pub struct Session<P>

One authenticated connection, bound permanently to its provider’s User.

pub fn new(provider: P) -> Self

Authentication belongs to the listener; no unauthenticated constructor or command can choose another User through this capability (#428).

pub async fn run<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin>(
&mut self,
reader: &mut crate::wire::CommandReader<S>,
idle_timeout: std::time::Duration,
) -> std::io::Result<()>

Run commands after TLS and App Password authentication. One subscription lasts for the connection, so IDLE entry cannot miss a committed change. No transport or authentication material escapes into provider errors.

pub async fn execute(&mut self, command: Command<'_>) -> Vec<u8>

Execute one decoded command. Unsupported requests fail before emitting partial FETCH data. Tags came from the codec’s validated atom grammar.

pub async fn refresh(&mut self, output: &mut Vec<u8>) -> Result<(), &'static str>

IDLE and NOOP share this reconciliation. Emit descending EXPUNGE sequence numbers, then EXISTS and MODSEQ; connection state changes only after a complete provider snapshot. An unchanged durable clock skips body reads; a changed clock retains the full atomic refresh (#428, #780).

Source: crates/calternal-imap/src/session.rs:25