package repr

  1. Overview
  2. Docs
type 'a t = private 'a Size.t =
  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 f: the length of binary encodings is dependent on the specific value, but may be efficiently computed at run-time via the function f.
  • Unknown: this codec may produce encodings that cannot be efficiently pre-computed.
val of_value : 'a Repr__.Type.t -> ('a -> int) t
val of_encoding : 'a Repr__.Type.t -> (string -> int -> int) t

Constructors for custom value sizers, for use with binary codecs that are not structurally-defined.

type -'a sizer
val t : 'a Repr__.Type.t -> 'a sizer
val using : ('b -> 'a) -> 'a sizer -> 'b sizer
val custom_static : int -> _ sizer
val custom_dynamic : ?of_value:('a -> int) -> ?of_encoding:(string -> int -> int) -> unit -> 'a sizer
OCaml

Innovation. Community. Security.