mailio_imap_map (mailio v0.2.0)
IMAP to JMAP mapping (pure).
Translates between IMAP wire concepts and Mailio's JMAP-shaped model: system flags and keywords, folder attributes and names and mailbox roles, and the per-mailbox sync cursor {uidvalidity, highestmodseq, uidnext} and an opaque adapter remote_state binary.
Summary
Functions
Decode an adapter state binary (or initial).
Encode a per-mailbox cursor into an opaque adapter state binary.
Map an IMAP system flag (or keyword) to a JMAP keyword. Unknown server keywords are lowercased; system flags map to their $ form.
Map a JMAP keyword back to an IMAP flag. Returns undefined for keywords that have no IMAP representation (kept local-only).
Stable mailbox id for an IMAP folder. The folder name is the adapter-native id; the sync engine maps it to a local mailbox id.
Determine a mailbox role from SPECIAL-USE attributes, falling back to well-known name heuristics. Returns undefined for ordinary folders.
Functions
-spec decode_state(binary() | initial) -> #{uidvalidity := non_neg_integer() | undefined, highestmodseq := non_neg_integer() | undefined, uidnext := non_neg_integer() | undefined}.
Decode an adapter state binary (or initial).
-spec encode_state(#{uidvalidity := non_neg_integer(), highestmodseq => non_neg_integer() | undefined, uidnext := non_neg_integer(), page => undefined | {added | updated, pos_integer(), non_neg_integer() | undefined}}) -> binary().
Encode a per-mailbox cursor into an opaque adapter state binary.
Map an IMAP system flag (or keyword) to a JMAP keyword. Unknown server keywords are lowercased; system flags map to their $ form.
Map a JMAP keyword back to an IMAP flag. Returns undefined for keywords that have no IMAP representation (kept local-only).
Stable mailbox id for an IMAP folder. The folder name is the adapter-native id; the sync engine maps it to a local mailbox id.
Determine a mailbox role from SPECIAL-USE attributes, falling back to well-known name heuristics. Returns undefined for ordinary folders.
-spec state_modseq(binary() | initial) -> non_neg_integer() | undefined.
-spec state_uidnext(binary() | initial) -> non_neg_integer() | undefined.
-spec state_uidvalidity(binary() | initial) -> non_neg_integer() | undefined.