diff --git a/src/util/Sidekick_util.ml b/src/util/Sidekick_util.ml index a492a241..fda8f3a4 100644 --- a/src/util/Sidekick_util.ml +++ b/src/util/Sidekick_util.ml @@ -23,5 +23,6 @@ module Stat = Stat module Hash = Hash module Profile = Profile module Chunk_stack = Chunk_stack +module Ser_value = Ser_value let[@inline] ( let@ ) f x = f x diff --git a/src/util/ser_value.ml b/src/util/ser_value.ml new file mode 100644 index 00000000..55eb7060 --- /dev/null +++ b/src/util/ser_value.ml @@ -0,0 +1,15 @@ +type t = + | Bool of bool + | Str of string + | Bytes of string + | Int of int + | List of t list + | Dict of t Util.Str_map.t + +let bool b : t = Bool b +let int i : t = Int i +let string x : t = Str x +let bytes x : t = Bytes x +let list x : t = List x +let dict x : t = Dict x +let dict_of_list l = dict (Util.Str_map.of_list l) diff --git a/src/util/ser_value.mli b/src/util/ser_value.mli new file mode 100644 index 00000000..da5a1aaf --- /dev/null +++ b/src/util/ser_value.mli @@ -0,0 +1,23 @@ +(** Serialization representation. + + A [Ser_value.t] describes how to serialized some structured + data into bytes. + It reflects the shape of the structured data but does not commit to a + particular serialization format. +*) + +type t = private + | Bool of bool + | Str of string + | Bytes of string + | Int of int + | List of t list + | Dict of t Util.Str_map.t + +val bool : bool -> t +val int : int -> t +val string : string -> t +val bytes : string -> t +val list : t list -> t +val dict : t Util.Str_map.t -> t +val dict_of_list : (string * t) list -> t