My agentic slop goes here. Not intended for anyone else!
1(** JMAP Id Type 2 3 The Id data type is used for all object ids throughout JMAP. 4 It is a string with minimum length 1 and maximum length 255 characters. 5 6 Reference: RFC 8620 Section 1.2 7*) 8 9(** Abstract type for JMAP identifiers *) 10type t = string 11 12(** Create an Id from a string. 13 @raise Invalid_argument if the string is empty or longer than 255 chars *) 14let of_string s = 15 let len = String.length s in 16 if len = 0 then 17 raise (Invalid_argument "Id cannot be empty") 18 else if len > 255 then 19 raise (Invalid_argument "Id cannot be longer than 255 characters") 20 else 21 s 22 23(** Convert an Id to a string *) 24let to_string t = t 25 26(** Parse an Id from JSON. 27 Expected JSON: string 28 29 Test files: 30 - test/data/core/request_get.json (ids field) 31 - test/data/mail/mailbox_get_request.json (accountId, ids) 32*) 33let of_json json = 34 match json with 35 | `String s -> of_string s 36 | _ -> raise (Jmap_error.Parse_error "Id must be a JSON string") 37 38(** Convert an Id to JSON *) 39let to_json t = `String t 40 41(** Compare two Ids for equality *) 42let equal (t1 : t) (t2 : t) = String.equal t1 t2 43 44(** Compare two Ids *) 45let compare (t1 : t) (t2 : t) = String.compare t1 t2 46 47(** Hash an Id *) 48let hash (t : t) = Hashtbl.hash t