Spindle_http.StructuredStructured Fields, as RFC 9651 defines them for the fields built on it: an item, a list or a dictionary, each value with parameters.
Structured.dictionary "a=1, b;q=5, c=(x \"y\")"
= Ok
[
("a", Item (Integer 1, []));
("b", Item (Boolean true, [ ("q", Integer 5) ]));
("c", Inner ([ (Token "x", []); (String "y", []) ], []));
]A field defines which of the three it is, so the caller says which it reads. A field given on several lines is read from its lines joined with ", " (RFC 9651 §4.2).
type bare = | Integer of intfifteen digits at most, signed
*)| Decimal of intthousandths: RFC 9651 bounds a decimal to three fractional digits, so 1.5 is 1500 and every decimal is exact
| String of stringprintable ASCII
*)| Token of string| Bytes of stringthe bytes, their base64 undone
*)| Boolean of bool| Date of Ptime.twhole seconds as a field holds it: one written with a fraction of a second is written in the second it is in, and one read outside the years 0 to 9999, which RFC 9651 allows and no instant holds, is refused
*)| Display of stringUTF-8, which a String cannot hold
*)type parameters = (string * bare) listIn order, each key once: a key given twice keeps its first place and its last value, as §4.2.3.2 has it.
type item = bare * parameterstype dictionary = (string * member) listIn order, each key once, as parameters.
val item : string -> (item, string) Stdlib.resultval list : string -> (member list, string) Stdlib.resultval dictionary : string -> (dictionary, string) Stdlib.resultval item_to_string : item -> (string, string) Stdlib.resultAn item as §4.1 writes it, or Error where it holds what no field can: an integer past fifteen digits, a decimal past twelve, a string with a character outside printable ASCII, a key or token that is not one, or a key given twice among one value's parameters or a dictionary's members. item reads it back as itself.
val list_to_string : member list -> (string, string) Stdlib.resultval dictionary_to_string : dictionary -> (string, string) Stdlib.result