2019-09-05 17:21:01 +04:00
|
|
|
(*****************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Open Source License *)
|
|
|
|
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* Permission is hereby granted, free of charge, to any person obtaining a *)
|
|
|
|
(* copy of this software and associated documentation files (the "Software"),*)
|
|
|
|
(* to deal in the Software without restriction, including without limitation *)
|
|
|
|
(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)
|
|
|
|
(* and/or sell copies of the Software, and to permit persons to whom the *)
|
|
|
|
(* Software is furnished to do so, subject to the following conditions: *)
|
|
|
|
(* *)
|
|
|
|
(* The above copyright notice and this permission notice shall be included *)
|
|
|
|
(* in all copies or substantial portions of the Software. *)
|
|
|
|
(* *)
|
|
|
|
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
|
|
|
|
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)
|
|
|
|
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)
|
|
|
|
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
|
|
|
|
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)
|
|
|
|
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)
|
|
|
|
(* DEALINGS IN THE SOFTWARE. *)
|
|
|
|
(* *)
|
|
|
|
(*****************************************************************************)
|
|
|
|
|
2019-10-17 13:45:27 +04:00
|
|
|
(** {1 Entity Accessor Signatures} *)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** The generic signature of a single data accessor (a single value
|
|
|
|
bound to a specific key in the hierarchical (key x value)
|
|
|
|
database). *)
|
|
|
|
module type Single_data_storage = sig
|
|
|
|
type t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type context = t
|
|
|
|
|
|
|
|
(** The type of the value *)
|
|
|
|
type value
|
|
|
|
|
|
|
|
(** Tells if the data is already defined *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val mem : context -> bool Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Retrieve the value from the storage bucket ; returns a
|
|
|
|
{!Storage_error} if the key is not set or if the deserialisation
|
|
|
|
fails *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val get : context -> value tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Retrieves the value from the storage bucket ; returns [None] if
|
|
|
|
the data is not initialized, or {!Storage_helpers.Storage_error}
|
|
|
|
if the deserialisation fails *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val get_option : context -> value option tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Allocates the storage bucket and initializes it ; returns a
|
|
|
|
{!Storage_error Existing_key} if the bucket exists *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val init : context -> value -> Raw_context.t tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Updates the content of the bucket ; returns a {!Storage_Error
|
|
|
|
Missing_key} if the value does not exists *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val set : context -> value -> Raw_context.t tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Allocates the data and initializes it with a value ; just
|
|
|
|
updates it if the bucket exists *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val init_set : context -> value -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** When the value is [Some v], allocates the data and initializes
|
|
|
|
it with [v] ; just updates it if the bucket exists. When the
|
|
|
|
valus is [None], delete the storage bucket when the value ; does
|
|
|
|
nothing if the bucket does not exists. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val set_option : context -> value option -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Delete the storage bucket ; returns a {!Storage_error
|
|
|
|
Missing_key} if the bucket does not exists *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val delete : context -> Raw_context.t tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Removes the storage bucket and its contents ; does nothing if
|
|
|
|
the bucket does not exists *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val remove : context -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
(** Variant of {!Single_data_storage} with gas accounting. *)
|
|
|
|
module type Single_carbonated_data_storage = sig
|
|
|
|
type t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type context = t
|
|
|
|
|
|
|
|
(** The type of the value *)
|
|
|
|
type value
|
|
|
|
|
|
|
|
(** Tells if the data is already defined.
|
|
|
|
Consumes [Gas_repr.read_bytes_cost Z.zero]. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val mem : context -> (Raw_context.t * bool) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Retrieve the value from the storage bucket ; returns a
|
|
|
|
{!Storage_error} if the key is not set or if the deserialisation
|
|
|
|
fails.
|
|
|
|
Consumes [Gas_repr.read_bytes_cost <size of the value>]. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val get : context -> (Raw_context.t * value) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Retrieves the value from the storage bucket ; returns [None] if
|
|
|
|
the data is not initialized, or {!Storage_helpers.Storage_error}
|
|
|
|
if the deserialisation fails.
|
|
|
|
Consumes [Gas_repr.read_bytes_cost <size of the value>] if present
|
|
|
|
or [Gas_repr.read_bytes_cost Z.zero]. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val get_option : context -> (Raw_context.t * value option) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Allocates the storage bucket and initializes it ; returns a
|
|
|
|
{!Storage_error Missing_key} if the bucket exists.
|
|
|
|
Consumes [Gas_repr.write_bytes_cost <size of the value>].
|
|
|
|
Returns the size. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val init : context -> value -> (Raw_context.t * int) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Updates the content of the bucket ; returns a {!Storage_Error
|
|
|
|
Existing_key} if the value does not exists.
|
|
|
|
Consumes [Gas_repr.write_bytes_cost <size of the new value>].
|
|
|
|
Returns the difference from the old to the new size. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val set : context -> value -> (Raw_context.t * int) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Allocates the data and initializes it with a value ; just
|
|
|
|
updates it if the bucket exists.
|
|
|
|
Consumes [Gas_repr.write_bytes_cost <size of the new value>].
|
2019-10-17 13:45:27 +04:00
|
|
|
Returns the difference from the old (maybe 0) to the new size, and a boolean
|
|
|
|
indicating if a value was already associated to this key. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val init_set :
|
|
|
|
context -> value -> (Raw_context.t * int * bool) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** When the value is [Some v], allocates the data and initializes
|
|
|
|
it with [v] ; just updates it if the bucket exists. When the
|
|
|
|
valus is [None], delete the storage bucket when the value ; does
|
|
|
|
nothing if the bucket does not exists.
|
|
|
|
Consumes the same gas cost as either {!remove} or {!init_set}.
|
2019-10-17 13:45:27 +04:00
|
|
|
Returns the difference from the old (maybe 0) to the new size, and a boolean
|
|
|
|
indicating if a value was already associated to this key. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val set_option :
|
|
|
|
context -> value option -> (Raw_context.t * int * bool) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Delete the storage bucket ; returns a {!Storage_error
|
|
|
|
Missing_key} if the bucket does not exists.
|
|
|
|
Consumes [Gas_repr.write_bytes_cost Z.zero].
|
|
|
|
Returns the freed size. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val delete : context -> (Raw_context.t * int) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Removes the storage bucket and its contents ; does nothing if
|
|
|
|
the bucket does not exists.
|
|
|
|
Consumes [Gas_repr.write_bytes_cost Z.zero].
|
2019-10-17 13:45:27 +04:00
|
|
|
Returns the freed size, and a boolean
|
|
|
|
indicating if a value was already associated to this key. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val remove : context -> (Raw_context.t * int * bool) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
(** Restricted version of {!Indexed_data_storage} w/o iterators. *)
|
|
|
|
module type Non_iterable_indexed_data_storage = sig
|
|
|
|
type t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type context = t
|
|
|
|
|
|
|
|
(** An abstract type for keys *)
|
|
|
|
type key
|
|
|
|
|
|
|
|
(** The type of values *)
|
|
|
|
type value
|
|
|
|
|
|
|
|
(** Tells if a given key is already bound to a storage bucket *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val mem : context -> key -> bool Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Retrieve a value from the storage bucket at a given key ;
|
|
|
|
returns {!Storage_error Missing_key} if the key is not set ;
|
|
|
|
returns {!Storage_error Corrupted_data} if the deserialisation
|
|
|
|
fails. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val get : context -> key -> value tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Retrieve a value from the storage bucket at a given key ;
|
|
|
|
returns [None] if the value is not set ; returns {!Storage_error
|
|
|
|
Corrupted_data} if the deserialisation fails. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val get_option : context -> key -> value option tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Updates the content of a bucket ; returns A {!Storage_Error
|
|
|
|
Missing_key} if the value does not exists. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val set : context -> key -> value -> Raw_context.t tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Allocates a storage bucket at the given key and initializes it ;
|
|
|
|
returns a {!Storage_error Existing_key} if the bucket exists. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val init : context -> key -> value -> Raw_context.t tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Allocates a storage bucket at the given key and initializes it
|
|
|
|
with a value ; just updates it if the bucket exists. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val init_set : context -> key -> value -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** When the value is [Some v], allocates the data and initializes
|
|
|
|
it with [v] ; just updates it if the bucket exists. When the
|
|
|
|
valus is [None], delete the storage bucket when the value ; does
|
|
|
|
nothing if the bucket does not exists. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val set_option : context -> key -> value option -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Delete a storage bucket and its contents ; returns a
|
|
|
|
{!Storage_error Missing_key} if the bucket does not exists. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val delete : context -> key -> Raw_context.t tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Removes a storage bucket and its contents ; does nothing if the
|
|
|
|
bucket does not exists. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val remove : context -> key -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
(** Variant of {!Non_iterable_indexed_data_storage} with gas accounting. *)
|
|
|
|
module type Non_iterable_indexed_carbonated_data_storage = sig
|
|
|
|
type t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type context = t
|
|
|
|
|
|
|
|
(** An abstract type for keys *)
|
|
|
|
type key
|
|
|
|
|
|
|
|
(** The type of values *)
|
|
|
|
type value
|
|
|
|
|
|
|
|
(** Tells if a given key is already bound to a storage bucket.
|
|
|
|
Consumes [Gas_repr.read_bytes_cost Z.zero]. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val mem : context -> key -> (Raw_context.t * bool) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Retrieve a value from the storage bucket at a given key ;
|
|
|
|
returns {!Storage_error Missing_key} if the key is not set ;
|
|
|
|
returns {!Storage_error Corrupted_data} if the deserialisation
|
|
|
|
fails.
|
|
|
|
Consumes [Gas_repr.read_bytes_cost <size of the value>]. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val get : context -> key -> (Raw_context.t * value) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Retrieve a value from the storage bucket at a given key ;
|
|
|
|
returns [None] if the value is not set ; returns {!Storage_error
|
|
|
|
Corrupted_data} if the deserialisation fails.
|
|
|
|
Consumes [Gas_repr.read_bytes_cost <size of the value>] if present
|
|
|
|
or [Gas_repr.read_bytes_cost Z.zero]. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val get_option :
|
|
|
|
context -> key -> (Raw_context.t * value option) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Updates the content of a bucket ; returns A {!Storage_Error
|
|
|
|
Missing_key} if the value does not exists.
|
|
|
|
Consumes serialization cost.
|
|
|
|
Consumes [Gas_repr.write_bytes_cost <size of the new value>].
|
|
|
|
Returns the difference from the old to the new size. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val set : context -> key -> value -> (Raw_context.t * int) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Allocates a storage bucket at the given key and initializes it ;
|
|
|
|
returns a {!Storage_error Existing_key} if the bucket exists.
|
|
|
|
Consumes serialization cost.
|
|
|
|
Consumes [Gas_repr.write_bytes_cost <size of the value>].
|
|
|
|
Returns the size. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val init : context -> key -> value -> (Raw_context.t * int) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Allocates a storage bucket at the given key and initializes it
|
|
|
|
with a value ; just updates it if the bucket exists.
|
|
|
|
Consumes serialization cost.
|
|
|
|
Consumes [Gas_repr.write_bytes_cost <size of the new value>].
|
2019-10-17 13:45:27 +04:00
|
|
|
Returns the difference from the old (maybe 0) to the new size, and a boolean
|
|
|
|
indicating if a value was already associated to this key. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val init_set :
|
|
|
|
context -> key -> value -> (Raw_context.t * int * bool) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** When the value is [Some v], allocates the data and initializes
|
|
|
|
it with [v] ; just updates it if the bucket exists. When the
|
|
|
|
valus is [None], delete the storage bucket when the value ; does
|
|
|
|
nothing if the bucket does not exists.
|
|
|
|
Consumes serialization cost.
|
|
|
|
Consumes the same gas cost as either {!remove} or {!init_set}.
|
2019-10-17 13:45:27 +04:00
|
|
|
Returns the difference from the old (maybe 0) to the new size, and a boolean
|
|
|
|
indicating if a value was already associated to this key. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val set_option :
|
|
|
|
context ->
|
|
|
|
key ->
|
|
|
|
value option ->
|
|
|
|
(Raw_context.t * int * bool) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Delete a storage bucket and its contents ; returns a
|
|
|
|
{!Storage_error Missing_key} if the bucket does not exists.
|
|
|
|
Consumes [Gas_repr.write_bytes_cost Z.zero].
|
|
|
|
Returns the freed size. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val delete : context -> key -> (Raw_context.t * int) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Removes a storage bucket and its contents ; does nothing if the
|
|
|
|
bucket does not exists.
|
|
|
|
Consumes [Gas_repr.write_bytes_cost Z.zero].
|
2019-10-17 13:45:27 +04:00
|
|
|
Returns the freed size, and a boolean
|
|
|
|
indicating if a value was already associated to this key. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val remove : context -> key -> (Raw_context.t * int * bool) tzresult Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
(** The generic signature of indexed data accessors (a set of values
|
|
|
|
of the same type indexed by keys of the same form in the
|
|
|
|
hierarchical (key x value) database). *)
|
|
|
|
module type Indexed_data_storage = sig
|
|
|
|
include Non_iterable_indexed_data_storage
|
|
|
|
|
|
|
|
(** Empties all the keys and associated data. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val clear : context -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Lists all the keys. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val keys : context -> key list Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Lists all the keys and associated data. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val bindings : context -> (key * value) list Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Iterates over all the keys and associated data. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val fold :
|
2019-09-05 17:21:01 +04:00
|
|
|
context -> init:'a -> f:(key -> value -> 'a -> 'a Lwt.t) -> 'a Lwt.t
|
|
|
|
|
|
|
|
(** Iterate over all the keys. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val fold_keys : context -> init:'a -> f:(key -> 'a -> 'a Lwt.t) -> 'a Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module type Indexed_data_snapshotable_storage = sig
|
|
|
|
type snapshot
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type key
|
|
|
|
|
|
|
|
include Indexed_data_storage with type key := key
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module Snapshot :
|
|
|
|
Indexed_data_storage
|
|
|
|
with type key = snapshot * key
|
|
|
|
and type value = value
|
|
|
|
and type t = t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
val snapshot_exists : context -> snapshot -> bool Lwt.t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
val snapshot : context -> snapshot -> Raw_context.t tzresult Lwt.t
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val delete_snapshot : context -> snapshot -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
(** The generic signature of a data set accessor (a set of values
|
|
|
|
bound to a specific key prefix in the hierarchical (key x value)
|
|
|
|
database). *)
|
|
|
|
module type Data_set_storage = sig
|
|
|
|
type t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type context = t
|
|
|
|
|
|
|
|
(** The type of elements. *)
|
|
|
|
type elt
|
|
|
|
|
|
|
|
(** Tells if a elt is a member of the set *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val mem : context -> elt -> bool Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Adds a elt is a member of the set *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val add : context -> elt -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Removes a elt of the set ; does nothing if not a member *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val del : context -> elt -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Adds/Removes a elt of the set *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val set : context -> elt -> bool -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Returns the elements of the set, deserialized in a list in no
|
|
|
|
particular order. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val elements : context -> elt list Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Iterates over the elements of the set. *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val fold : context -> init:'a -> f:(elt -> 'a -> 'a Lwt.t) -> 'a Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Removes all elements in the set *)
|
2020-02-12 20:40:17 +04:00
|
|
|
val clear : context -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module type NAME = sig
|
2020-02-12 20:40:17 +04:00
|
|
|
val name : Raw_context.key
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module type VALUE = sig
|
|
|
|
type t
|
2019-10-17 13:45:27 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val encoding : t Data_encoding.t
|
|
|
|
end
|
2019-10-17 13:45:27 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module type REGISTER = sig
|
|
|
|
val ghost : bool
|
2019-10-17 13:45:27 +04:00
|
|
|
end
|
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
module type Indexed_raw_context = sig
|
|
|
|
type t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type context = t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type key
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type 'a ipath
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val clear : context -> Raw_context.t Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val fold_keys : context -> init:'a -> f:(key -> 'a -> 'a Lwt.t) -> 'a Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val keys : context -> key list Lwt.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val resolve : context -> string list -> key list Lwt.t
|
2019-10-17 13:45:27 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val remove_rec : context -> key -> context Lwt.t
|
2019-10-17 13:45:27 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val copy : context -> from:key -> to_:key -> context tzresult Lwt.t
|
2019-10-17 13:45:27 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module Make_set (R : REGISTER) (N : NAME) :
|
|
|
|
Data_set_storage with type t = t and type elt = key
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module Make_map (N : NAME) (V : VALUE) :
|
|
|
|
Indexed_data_storage
|
|
|
|
with type t = t
|
|
|
|
and type key = key
|
|
|
|
and type value = V.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module Make_carbonated_map (N : NAME) (V : VALUE) :
|
|
|
|
Non_iterable_indexed_carbonated_data_storage
|
|
|
|
with type t = t
|
|
|
|
and type key = key
|
|
|
|
and type value = V.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Raw_context : Raw_context.T with type t = t ipath
|
|
|
|
end
|