package datakit

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Blob are lists of cstructs, with constant-time append operations. This is optimized to store large files where contents is always appended (e.g. log files).

include Irmin.Contents.S

Signature for store contents

type t

The type for user-defined contents.

val t : t Irmin.Type.t

t is the value type for t.

val pp : t Fmt.t

pp pretty-prints contents.

val of_string : string -> (t, [ `Msg of string ]) Result.result

of_string parses contents.

val merge : t option Irmin.Merge.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.

val empty : t

The empty blob.

val write : t -> offset:int64 -> Cstruct.t -> (t, Vfs.Error.t) Pervasives.result

write t ~offset data is the blob t overwritten with data at offset. The new blob is extended and zero-filled as necessary. If offset = len t then this is very fast.

val len : t -> int64
val truncate : t -> int64 -> (t, Vfs.Error.t) Pervasives.result

truncate t l is a blob of length l. If l <= len t then it is the prefix of t of length l. If l > len t then it is t followed by enough zero bytes to make up the length. Return an error if the requested length is negative.

val read : t -> offset:int64 -> count:int -> (Cstruct.t, Vfs.Error.t) Pervasives.result

read t ~offset ~count is the count bytes in t starting at offset. If the blob is not long enough to return count bytes, then it returns as many as possible. Return an error if offset < 0 || offset > len t.

val ro_cstruct : Cstruct.t -> t

ro_cstruct c is a blob containing the data c. Note that we take a reference to c rather than copying, so c MUST NOT be modified after this call. c may also be shared with modified versions of the resulting blob.

val to_ro_cstruct : t -> Cstruct.t

to_ro_cstruct t is a read-only Cstruct with the same data as t. DO NOT modify this - it may corrupt the blob or other blobs sharing data with this one if you do.

val string : string -> t

string s is a blob containing the same data as s.

val to_string : t -> string

to_string t is a string containing the same data as t.

val compare : t -> t -> int

compare is the comparison function for blobs. It is very slow, so use it with care!

OCaml

Innovation. Community. Security.