Module Webs_session.State

State descriptors.

FIXME. encode allow errors ? pp ? Ideally this would simply take a typegist.

type 'a t

The type for describing session state of type 'a. Values of this type describe to session handlers how codec values of type 'a with bytes and assert them for equality.

val make : encode:('a -> string) -> decode:(string -> ('a, string) Stdlib.result) -> equal:('a -> 'a -> bool) -> unit -> 'a t

make ~encode ~decode ~equal () tests state for equality with eq, encodes states to bytes with encode, decodes states from bytes with decode and tests state for equality with equal

val encode : 'a t -> 'a -> string

encode sd is the encoding function of sd.

val decode : 'a t -> string -> ('a, string) Stdlib.result

decode sd is the decoding function of sd.

val equal : 'a t -> 'a -> 'a -> bool

equal sd is the equality function of sd.

val option_equal : 'a t -> 'a option -> 'a option -> bool

option_equal sd is equal trivially extended to optional state.