Imandrakit_ser_pack.SerSerialization
State used for serialization.
It contains an in-progress heap, and a hash table for hashconsing.
val create : unit -> stateNew state.
type ptr = valueAn integer + tag for value
val unit : valueBuild a value null
val int64 : int64 -> valueBuild a value integer
val int : int -> valueBuild a value integer
val bool : bool -> valueBuild a value bool
val float : float -> valueBuild a value float
val string : string -> valueBuild a value text string (UTF8)
val bytes : string -> valueBuild a value blob (raw bytes)
val dict : value Imandrakit_common.Str_map.t -> valueadd_entry st c turns c into a heap entry and returns a pointer to it. The pointer is a small value value (a tagged integer).
add_entry_hashcons st c turns c into a heap entry. c is first compared to existing hashconsed entries (at a runtime cost) to see if we can reuse them instead of inserting a new value.
Same as add_entry state (`Text s), except that large strings will be hashconsed unconditionally.
Same as add_string
fix f is a recursive serializer. f receives a serializer for recursive cases and must use it to implement the serialization for the current value.
val create_cache_key : 
  (module Stdlib.Hashtbl.HashedType with type t = 'a) ->
  'a cache_keyCreate a new (generative) cache key for a hashable + comparable type.
NOTE this should be called only at module toplevel, as a constant, not dynamically inside a function: let key = value_pack.Ser.create_cache_key (module …);;. Indeed, this is generative, so creating multiple keys for a type will result in sub-par or inexistant caching.
with_cache key enc is the same encoder as enc, but with caching. When encoding a value x:'a, the cache key is used to detect if x was already encoded to some entry, and uses a pointer to this entry instead of re-serializing x.
Turn the state into a pack with given key as entrypoint.
Same as finalize_value but also turns the resulting packed value into a string.