IMAP in OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 43 lines 1.0 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** SORT Criteria 7 8 Sort keys for the SORT command as specified in RFC 5256. *) 9 10type key = 11 | Arrival 12 | Cc 13 | Date 14 | From 15 | Size 16 | Subject 17 | To 18 19type criterion = { 20 reverse : bool; 21 key : key; 22} 23 24type t = criterion list 25 26let key k = { reverse = false; key = k } 27let reverse k = { reverse = true; key = k } 28 29let pp_key ppf = function 30 | Arrival -> Fmt.string ppf "ARRIVAL" 31 | Cc -> Fmt.string ppf "CC" 32 | Date -> Fmt.string ppf "DATE" 33 | From -> Fmt.string ppf "FROM" 34 | Size -> Fmt.string ppf "SIZE" 35 | Subject -> Fmt.string ppf "SUBJECT" 36 | To -> Fmt.string ppf "TO" 37 38let pp_criterion ppf c = 39 if c.reverse then Fmt.pf ppf "REVERSE %a" pp_key c.key 40 else pp_key ppf c.key 41 42let pp ppf criteria = 43 Fmt.(list ~sep:sp pp_criterion) ppf criteria