(*--------------------------------------------------------------------------- Copyright (c) 2025 Anil Madhavapeddy . All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Response Codes IMAP response codes as specified in RFC 9051 Section 7.1. *) type t = | Alert | Alreadyexists | Appenduid of int64 * int64 (** uidvalidity, uid *) | Authenticationfailed | Authorizationfailed | Badcharset of string list | Cannot | Capability of string list | Clientbug | Closed | Contactadmin | Copyuid of int64 * Seq.t * Seq.t (** uidvalidity, source, dest *) | Corruption | Expired | Expungeissued | Haschildren | Highestmodseq of int64 (** Highest MODSEQ in mailbox - RFC 7162 CONDSTORE *) | Inuse | Limit | Modified of Seq.t (** Messages modified since UNCHANGEDSINCE - RFC 7162 CONDSTORE *) | Nomodseq (** Mailbox doesn't support MODSEQ - RFC 7162 CONDSTORE *) | Nonexistent | Noperm | Overquota | Parse | Permanentflags of Flag.t list | Privacyrequired | Readonly | Readwrite | Serverbug | Trycreate | Uidnotsticky | Uidvalidity of int64 | Uidnext of int64 | Unavailable | Unknown_cte | Other of string * string option let pp ppf = function | Alert -> Fmt.string ppf "ALERT" | Alreadyexists -> Fmt.string ppf "ALREADYEXISTS" | Appenduid (v, u) -> Fmt.pf ppf "APPENDUID %Ld %Ld" v u | Authenticationfailed -> Fmt.string ppf "AUTHENTICATIONFAILED" | Authorizationfailed -> Fmt.string ppf "AUTHORIZATIONFAILED" | Badcharset cs -> Fmt.pf ppf "BADCHARSET (%a)" Fmt.(list ~sep:sp string) cs | Cannot -> Fmt.string ppf "CANNOT" | Capability caps -> Fmt.pf ppf "CAPABILITY %a" Fmt.(list ~sep:sp string) caps | Clientbug -> Fmt.string ppf "CLIENTBUG" | Closed -> Fmt.string ppf "CLOSED" | Contactadmin -> Fmt.string ppf "CONTACTADMIN" | Copyuid (v, s, d) -> Fmt.pf ppf "COPYUID %Ld %a %a" v Seq.pp s Seq.pp d | Corruption -> Fmt.string ppf "CORRUPTION" | Expired -> Fmt.string ppf "EXPIRED" | Expungeissued -> Fmt.string ppf "EXPUNGEISSUED" | Haschildren -> Fmt.string ppf "HASCHILDREN" | Highestmodseq m -> Fmt.pf ppf "HIGHESTMODSEQ %Ld" m | Inuse -> Fmt.string ppf "INUSE" | Limit -> Fmt.string ppf "LIMIT" | Modified s -> Fmt.pf ppf "MODIFIED %a" Seq.pp s | Nomodseq -> Fmt.string ppf "NOMODSEQ" | Nonexistent -> Fmt.string ppf "NONEXISTENT" | Noperm -> Fmt.string ppf "NOPERM" | Overquota -> Fmt.string ppf "OVERQUOTA" | Parse -> Fmt.string ppf "PARSE" | Permanentflags fs -> Fmt.pf ppf "PERMANENTFLAGS (%a)" Fmt.(list ~sep:sp Flag.pp) fs | Privacyrequired -> Fmt.string ppf "PRIVACYREQUIRED" | Readonly -> Fmt.string ppf "READ-ONLY" | Readwrite -> Fmt.string ppf "READ-WRITE" | Serverbug -> Fmt.string ppf "SERVERBUG" | Trycreate -> Fmt.string ppf "TRYCREATE" | Uidnotsticky -> Fmt.string ppf "UIDNOTSTICKY" | Uidvalidity v -> Fmt.pf ppf "UIDVALIDITY %Ld" v | Uidnext u -> Fmt.pf ppf "UIDNEXT %Ld" u | Unavailable -> Fmt.string ppf "UNAVAILABLE" | Unknown_cte -> Fmt.string ppf "UNKNOWN-CTE" | Other (name, arg) -> Fmt.string ppf name; Option.iter (Fmt.pf ppf " %s") arg let to_string c = Fmt.str "%a" pp c