package irmin-unix

  1. Overview
  2. Docs

Tree provides immutable, in-memory partial mirror of the store, with lazy reads and delayed writes.

Trees are like staging area in Git: they are immutable temporary non-persistent areas (they disappear if the host crash), held in memory for efficiency, where reads are done lazily and writes are done only when needed on commit: if you modify a key twice, only the last change will be written to the store when you commit.

Constructors

val empty : tree

empty is the empty tree. The empty tree does not have associated backend configuration values, as they can perform in-memory operation, independently of any given backend.

val of_contents : ?metadata:metadata -> contents -> tree

of_contents c is the subtree built from the contents c.

val of_node : node -> tree

of_node n is the subtree built from the node n.

val kind : tree -> key -> [ `Contents | `Node ] option Lwt.t

kind t k is the type of s in t. It could either be a tree node or some file contents. It is None if k is not present in t.

val list : tree -> key -> (step * [ `Contents | `Node ]) list Lwt.t

list t key is the list of files and sub-nodes stored under k in t.

Diffs

val diff : tree -> tree -> (key * (contents * metadata) Irmin.diff) list Lwt.t

diff x y is the difference of contents between x and y.

Manipulating Contents

val mem : tree -> key -> bool Lwt.t

mem t k is true iff k is associated to some contents in t.

val find_all : tree -> key -> (contents * metadata) option Lwt.t

find_all t k is Some (b, m) if k is associated to the contents b and metadata m in t and None if k is not present in t.

val find : tree -> key -> contents option Lwt.t

find is similar to find_all but it discards metadata.

val get_all : tree -> key -> (contents * metadata) Lwt.t

Same as find_all but raise Invalid_arg if k is not present in t.

val get : tree -> key -> contents Lwt.t

Same as get_all but ignore the metadata.

val add : tree -> key -> ?metadata:metadata -> contents -> tree Lwt.t

add t k c is the tree where the key k is bound to the contents c but is similar to t for other bindings.

val remove : tree -> key -> tree Lwt.t

remove t k is the tree where k bindings has been removed but is similar to t for other bindings.

Manipulating Subtrees

val mem_tree : tree -> key -> bool Lwt.t

mem_tree t k is false iff find_tree k = None.

val find_tree : tree -> key -> tree option Lwt.t

find_tree t k is Some v if k is associated to v in t. It is None if k is not present in t.

val get_tree : tree -> key -> tree Lwt.t

get_tree t k is v if k is associated to v in t. Raise Invalid_arg if k is not present in t.

val add_tree : tree -> key -> tree -> tree Lwt.t

add_tree t k v is the tree where the key k is bound to the tree v but is similar to t for other bindings

val merge : tree Irmin.Merge.t

merge is the 3-way merge function for trees.

Concrete Trees

type concrete = [
  1. | `Tree of (step * concrete) list
  2. | `Contents of contents * metadata
]

The type for concrete trees.

val of_concrete : concrete -> tree

of_concrete c is the subtree equivalent to the concrete tree c.

val to_concrete : tree -> concrete Lwt.t

to_concrete t is the concrete tree equivalent to the subtree t.

Import/Export

module Hash : Irmin.Hash.S with type t = H.t

Hash provides base functions for node hashes.

type hash = [
  1. | `Node of Hash.t
  2. | `Contents of Contents.Hash.t * metadata
]

The type for tree hashes.

val hash_t : hash Irmin.Type.t

hash_t is the representation of the hash type.

val hash : repo -> tree -> hash Lwt.t

hash r c it c's hash in the repository r.

val of_hash : repo -> hash -> tree option Lwt.t

of_hash r h is the the tree object in r having h as hash, or None is no such tree object exists.

OCaml

Innovation. Community. Security.