Imandrakit_ser_pack.Deser
Deserialization
A deserializer takes a value value, and returns a value of type 'a
from it.
val return : 'a -> 'a t
val failf : ('a, unit, string, 'b) format4 -> 'a
Fail to decode with a formatted message.
val to_unit : unit t
val to_int : int t
val to_int64 : int64 t
val to_bool : bool t
val to_float : float t
val to_dict : value Imandrakit_common.Str_map.t t
val to_text : string t
val to_bytes : string t
val ptr_of_int : int -> ptr
Entry point
val parse_exn : string -> state
val create_cache_key : unit -> _ cache_key
Generate a new (generative) cache key for a type.
NOTE this should be called only at module toplevel, as a constant, not dynamically inside a function: let key: foo value_pack.Deser.cache_key = value_pack.Deser.create_cache_key ();;
. Indeed, this is generative, so creating multiple keys for a type will result in sub-par or inexistant caching.
with_cache key dec
is the same decoder as dec
but it uses key
to retrieve values directly from an internal table for entries/values that have already been decoded in the past. This means that a value that was encoded with a lot of sharing (e.g in a graph, or a large string using Ser.add_string
) will be decoded only once.
fix f
is a recursive deserializer. f
receives a deserializer for recursive cases and must use it to implement the deserialization for the current value.
Entrypoint for the pack, as used in Ser.finalize_value
or Ser.finalize_string
val show_diagnostic : state -> string
Show the content of the deserialized value using the diagnostic notation
val pp_diagnostic : Stdlib.Format.formatter -> state -> unit
Show the content of the deserialized value using the diagnostic notation