123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185(*
* Copyright (c) 2018-2021 Tarides <contact@tarides.com>
*
* 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!ImportmoduletypeValue=sigincludeIrmin.Private.Node.Svalpred:t->[`Nodeofhash|`Inodeofhash|`Contentsofhash]listendmoduletypeS=sigincludeIrmin.CONTENT_ADDRESSABLE_STOREmoduleKey:Irmin.Hash.Swithtypet=keymoduleVal:Valuewithtypet=valueandtypehash=keyvaldecode_bin_length:string->int->intvalbatch:readt->([read|write]t->'aLwt.t)->'aLwt.tvalclose:_t->unitLwt.tendmoduletypePersistent=sigincludeStypeindexvalv:?fresh:bool->?readonly:bool->?lru_size:int->index:index->string->readtLwt.tincludeS.Checkablewithtype'at:='atandtypekey:=keyvalsync:?on_generation_change:(unit->unit)->'at->unitvalclear_caches:'at->unitvalintegrity_check_inodes:[`Read]t->key->(unit,string)resultLwt.tend(** Unstable internal API agnostic about the underlying storage. Use it only to
implement or test inodes. *)moduletypeInternal=sigtypehashvalpp_hash:hashFmt.texceptionDangling_hashof{context:string;hash:hash}moduleRaw:Pack_value.Swithtypehash=hashmoduleVal:sigincludeValuewithtypehash=hashvalof_raw:(hash->Raw.toption)->Raw.t->tvalto_raw:t->Raw.tvalsave:add:(hash->Raw.t->unit)->mem:(hash->bool)->t->unitvalhash:t->hashvalstable:t->boolvallength:t->intvalindex:depth:int->step->intvalintegrity_check:t->bool(** Checks the integrity of an inode. *)moduleConcrete:sig(** {1 Concrete trees} *)(** The type for pointer kinds. *)typekind=Contents|Contents_xofmetadata|Node[@@derivingirmin]typeentry={name:step;kind:kind;hash:hash}[@@derivingirmin](** The type for entries. *)type'apointer={index:int;pointer:hash;tree:'a}[@@derivingirmin](** The type for pointers. *)type'atree={depth:int;length:int;pointers:'apointerlist}[@@derivingirmin](** The type for trees. *)(** The type for concrete trees. *)typet=Treeofttree|Valuesofentrylist|Blinded[@@derivingirmin]typelen:=[`Eqofint|`Geofint]typeerror=[`Invalid_hashofhash*hash*t|`Invalid_depthofint*int*t|`Invalid_lengthoflen*int*t|`Duplicated_entriesoft|`Duplicated_pointersoft|`Unsorted_entriesoft|`Unsorted_pointersoft|`Blinded_root|`Empty][@@derivingirmin](** The type for errors. *)valpp_error:errorFmt.t(** [pp_error] is the pretty-printer for errors. *)endvalto_concrete:t->Concrete.t(** [to_concrete t] is the concrete inode tree equivalent to [t]. *)valof_concrete:Concrete.t->(t,Concrete.error)result(** [of_concrete c] is [Ok t] iff [c] and [t] are equivalent.
The result is [Error e] when a subtree tree of [c] has an integrity
error. *)moduleProof:sigvalof_concrete:Concrete.t->proofvalto_concrete:proof->Concrete.tendendendmoduletypeSigs=sigmoduletypeS=SmoduletypePersistent=PersistentmoduletypeInternal=InternalmoduleMake_internal(Conf:Conf.S)(H:Irmin.Hash.S)(Node:Irmin.Private.Node.Swithtypehash=H.t):Internalwithtypehash=H.tandtypeVal.metadata=Node.metadataandtypeVal.step=Node.stepmoduleMake(H:Irmin.Hash.S)(Node:Irmin.Private.Node.Swithtypehash=H.t)(Inter:Internalwithtypehash=H.tandtypeVal.metadata=Node.metadataandtypeVal.step=Node.step)(Pack:Content_addressable.Swithtypekey=H.tandtypevalue=Inter.Raw.t):Swithtype'at='aPack.tandtypekey=H.tandtypeVal.metadata=Node.metadataandtypeVal.step=Node.stepandtypevalue=Inter.Val.tmoduleMake_persistent(H:Irmin.Hash.S)(Node:Irmin.Private.Node.Swithtypehash=H.t)(Inter:Internalwithtypehash=H.tandtypeVal.metadata=Node.metadataandtypeVal.step=Node.step)(CA:Pack_store.Makerwithtypekey=H.tandtypeindex=Pack_index.Make(H).t):sigincludePersistentwithtypekey=H.tandtypeVal.metadata=Node.metadataandtypeVal.step=Node.stepandtypeindex=Pack_index.Make(H).tandtypevalue=Inter.Val.tendend