1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192(*
* Copyright (c) 2013-2017 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!ImportopenSmoduletypeS=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=sigincludeCONTENT_ADDRESSABLE_STOREvalmerge:[>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 {!Contents.S.merge}.
If any of these operations fail, return [`Conflict]. *)(** [Key] provides base functions for user-defined contents keys. *)moduleKey:Hash.TYPEDwithtypet=keyandtypevalue=valuemoduleVal:Swithtypet=value(** [Val] provides base functions for user-defined contents values. *)endmoduletypeContents=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. *)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(C:sigincludeS.CONTENT_ADDRESSABLE_STOREmoduleKey:Hash.Swithtypet=keymoduleVal:Swithtypet=valueend):STOREwithtype'at='aC.tandtypekey=C.keyandtypevalue=C.valueend