package octez-libs
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=aa2f5bc99cc4ca2217c52a1af2a2cdfd3b383208cb859ca2e79ca0903396ca1d
sha512=d68bb3eb615e3dcccc845fddfc9901c95b3c6dc8e105e39522ce97637b1308a7fa7aa1d271351d5933febd7476b2819e1694f31198f1f0919681f1f9cc97cb3a
doc/octez-libs.tree-encoding/Tezos_tree_encoding/index.html
Module Tezos_tree_encodingSource
A key in the tree is a list of string.
Types
Represents a partial encoder for a specific constructor of a sum-type.
Represents an encoder and a decoder.
Functions
return x is an encoder that does nothing on encoding. On decoding it ignores the tree and returns x.
conv f g enc transforms from one encoding to a different one using f for mapping the results decoded using enc, and g for mapping from the input.
It is the user's responsibility to ensure that f and g are inverses, that is, that f (g x) = g (f x) for all x.
conv_lwt f g enc is the same as conv but where f and g are effectful (produce lwt promises).
It is the user's responsibility to ensure that f and g are inverses, that is, that f (g x) = g (f x) for all x.
tup2 ~flatten e1 e2 combines e1 and e2 into an encoder for pairs. If flatten is true, the elements are encoded directly under the given tree, otherwise each element is wrapped under an index node to avoid colliding keys.
Example: encode (tup2 ~flatten:false (value [] Data_encoding.string) (value [] Data_encoding.string)) (("A", "B"))
Gives a tree: "A" "B"
While encode (tup2 ~flatten:true (value [] Data_encoding.string) (value [] Data_encoding.string)) (("A", "B"))
Gives a tree: 1 -> "A" 2 -> "B"
tup3 ?flatten e1 e2 e3 combines the given encoders e1 .. e3 into an encoder for a tuple of three elements.
tup4 ?flatten e1 e2 e3 e4 combines the given encoders e1 .. e4 into an encoder for a tuple of four elements.
tup5 ?flatten e1 e2 e3 e4 e5 combines the given encoders e1 .. e5 into an encoder for a tuple of five elements.
val tup6 :
flatten:bool ->
'a t ->
'b t ->
'c t ->
'd t ->
'e t ->
'f t ->
('a * 'b * 'c * 'd * 'e * 'f) ttup6 ?flatten e1 e2 e3 e4 e5 e6 combines the given encoders e1 .. e6 into an encoder for a tuple of six elements.
val tup7 :
flatten:bool ->
'a t ->
'b t ->
'c t ->
'd t ->
'e t ->
'f t ->
'g t ->
('a * 'b * 'c * 'd * 'e * 'f * 'g) ttup7 ?flatten e1 e2 e3 e4 e5 e6 e7 combines the given encoders e1 .. e7 into an encoder for a tuple of seven elements.
val tup8 :
flatten:bool ->
'a t ->
'b t ->
'c t ->
'd t ->
'e t ->
'f t ->
'g t ->
'h t ->
('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) ttup8 ?flatten e1 e2 e3 e4 e5 e6 e7 e8 combines the given encoders e1 .. e8 into an encoder for a tuple of eight elements.
val tup9 :
flatten:bool ->
'a t ->
'b t ->
'c t ->
'd t ->
'e t ->
'f t ->
'g t ->
'h t ->
'i t ->
('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) ttup9 ~flatten e1 e2 e3 e4 e5 e6 e7 e8 e9 combines the given encoders e1 .. e9 into an encoder for a tuple of nine elements.
val tup10 :
flatten:bool ->
'a t ->
'b t ->
'c t ->
'd t ->
'e t ->
'f t ->
'g t ->
'h t ->
'i t ->
'j t ->
('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i * 'j) ttup10 ~flatten e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 combines the given encoders e1 .. e10 into an encoder for a tuple of ten elements.
value_option key encoding returns an encoder that uses encoding for encoding values, but does not fail if the key is absent.
value ?default key enc creates an encoder under the given key using the provided data-encoding enc for encoding/decoding values, and using default as a fallback when decoding in case the key is absent from the tree.
scope key enc moves the given encoder enc to encode values under a branch key.
case tag enc inj proj returns a partial encoder that represents a case in a sum-type. The encoder hides the (existentially bound) type of the parameter to the specific case, provided converter functions inj and proj for the base encoder enc.
case_lwt tag enc inj proj same as case tag enc inj proj but where inj and proj returns in lwt values.
tagged_union tag_enc cases returns an encoder that use tag_enc for encoding the value of a field tag. The encoder searches through the list of cases for a matching branch. When a matching branch is found, it uses its embedded encoder for the value. This function is used for constructing encoders for sum-types.
The default labeled argument can be provided to have a fallback in case the value is missing from the tree.
option enc lifts the given encoding enc to one that can encode optional values.
delayed f produces a tree encoder/decoder that delays evaluation of f () until the encoder or decoder is actually needed. This is required to allow for directly recursive encoders/decoders.
either enc_a enc_b returns an encoder where enc_a is used for the left case of Either.t, and enc_b for the Right case.
wrapped_tree is a tree encoding for wrapped tree.