-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Summary
Requesting implementation of the IMAP SORT command (RFC 5256) in swift-nio-imap.
Current state
Some groundwork already exists:
| Component | Status |
|---|---|
| Capability parsing | ✅ Capability.context(.sort), Capability.sort(_:), SortKind |
| Response parsing | ✅ SortData model + parseSortData in GrammarParser.swift (line ~2388) |
| Response encoding | ✅ writeSortData in EncodeBuffer |
| Command encoding | ❌ No .sort / .uidSort cases in Command enum |
| Sort criteria model | ❌ No SortKey / SortCriterion type (DATE, FROM, SUBJECT, SIZE, etc.) |
| Command parser | ❌ No parseSort in command parser |
So the response side is ready, but there's no way to send a SORT command.
What's needed
-
Sort criteria type — e.g.
SortCriterionenum with cases fordate,from,subject,to,cc,size,arrival, plusreverse(_:)modifier. RFC 5256 §3:sort-key = "ARRIVAL" / "CC" / "DATE" / "FROM" / "REVERSE" SP sort-key / "SIZE" / "SUBJECT" / "TO" / "DISPLAYFROM" / "DISPLAYTO" -
Command cases —
.sortand.uidSortonCommand:case sort(criteria: [SortCriterion], charset: String, key: SearchKey, returnOptions: [SearchReturnOption]) case uidSort(criteria: [SortCriterion], charset: String, key: SearchKey, returnOptions: [SearchReturnOption])
-
Command encoding — Wire format:
SORT (DATE REVERSE SUBJECT) UTF-8 UNSEEN -
Command parser (for server-side / testing) — Parse the SORT command from wire format.
Motivation
SORT is widely supported (iCloud, Dovecot, many others) and is the most-requested missing IMAP feature in our client library SwiftMail — see Cocoanetics/SwiftMail#11. The response-side support is already in place, so this is primarily about the command side.
References
- RFC 5256 — Internet Message Access Protocol - SORT and THREAD Extensions
- RFC 5267 — Contexts for IMAP4 (ESORT) — extends SORT with return options
- Related capability:
SORT=DISPLAY(RFC 5957) for DISPLAYFROM/DISPLAYTO sort keys