mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 11:15:43 -05:00
feat(util): add Ser_value
This commit is contained in:
parent
a313918e74
commit
d518511c64
3 changed files with 39 additions and 0 deletions
|
|
@ -23,5 +23,6 @@ module Stat = Stat
|
||||||
module Hash = Hash
|
module Hash = Hash
|
||||||
module Profile = Profile
|
module Profile = Profile
|
||||||
module Chunk_stack = Chunk_stack
|
module Chunk_stack = Chunk_stack
|
||||||
|
module Ser_value = Ser_value
|
||||||
|
|
||||||
let[@inline] ( let@ ) f x = f x
|
let[@inline] ( let@ ) f x = f x
|
||||||
|
|
|
||||||
15
src/util/ser_value.ml
Normal file
15
src/util/ser_value.ml
Normal file
|
|
@ -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)
|
||||||
23
src/util/ser_value.mli
Normal file
23
src/util/ser_value.mli
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Reference in a new issue