Module Bin.Size

type -'a size_of

The type for size function related to binary encoder/decoder.

val size_of : 'a t -> 'a size_of
type 'a t = private
  1. | Static of int
  2. | Dynamic of 'a
  3. | Unknown
    (*

    A value representing information known about the length in bytes of encodings produced by a particular binary codec:

    • Static n: all encodings produced by this codec have length n;
    • Dynamic fn: the length of binary encodings is dependent on the specific value, but may be efficiently computed at run-time via the function fn;
    • Unknown: this codec may produce encodings that cannot be efficiently pre-computed.
    *)
val of_encoding : 'a size_of -> (Bstr.t -> int -> int) t
val of_value : 'a size_of -> ('a -> int) t