123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107(*
* Copyright (c) 2013-2022 Thomas Gazagnaire <thomas@gazagnaire.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)open!ImportmoduletypeS=sig(** {1 Signature for store contents} *)typet[@@derivingirmin](** The type for user-defined contents. *)valmerge:toptionMerge.t(** Merge function. Evaluates to [`Conflict msg] if the values cannot be
merged properly. The arguments of the merge function can take [None] to
mean that the key does not exists for either the least-common ancestor or
one of the two merging points. The merge function returns [None] when the
key's value should be deleted. *)endmoduletypeStore=sigincludeIndexable.Svalmerge:[>read_write]t->keyoptionMerge.t(** [merge t] lifts the merge functions defined on contents values to contents
key. The merge function will: {e (i)} read the values associated with the
given keys, {e (ii)} use the merge function defined on values and
{e (iii)} write the resulting values into the store to get the resulting
key. See {!module-type-S.val-merge}.
If any of these operations fail, return [`Conflict]. *)moduleVal:Swithtypet=valuemoduleHash:Hash.Typedwithtypet=hashandtypevalue=valueendmoduletypeSigs=sigmoduletypeS=SmoduleString:Swithtypet=string(** Contents of type [string], with the {{!Irmin.Merge.default} default} 3-way
merge strategy: assume that update operations are idempotent and conflict
iff values are modified concurrently. *)moduleString_v2:Swithtypet=string(** Similar to [String] above, but the hash computation is compatible with
versions older than irmin.3.0 *)typejson=[`Null|`Boolofbool|`Stringofstring|`Floatoffloat|`Oof(string*json)list|`Aofjsonlist]moduleJson:Swithtypet=(string*json)list(** [Json] contents are associations from strings to [json] values stored as
JSON encoded strings. If the same JSON key has been modified concurrently
with different values then the [merge] function conflicts. *)moduleJson_value:Swithtypet=json(** [Json_value] allows any kind of json value to be stored, not only objects. *)moduleV1:sigmoduleString:Swithtypet=string(** Same as {!String} but use v1 serialisation format. *)endmoduletypeStore=Store(** Contents store. *)(** [Store] creates a contents store. *)moduleStore(S:Content_addressable.S)(H:Hash.Swithtypet=S.key)(C:Swithtypet=S.value):Storewithtype'at='aS.tandtypekey=H.tandtypehash=H.tandtypevalue=C.t(** [Store_indexable] is like {!module-Store} but uses an indexable store as a
backend (rather than a content-addressable one). *)moduleStore_indexable(S:Indexable.S)(H:Hash.Swithtypet=S.hash)(C:Swithtypet=S.value):Storewithtype'at='aS.tandtypekey=S.keyandtypevalue=S.valueandtypehash=S.hashend