package git

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

The functor to make the lazy decoder of the IDX file. Internally, we use a Cstruct.t representation of the IDX file notified to the make function. This Cstruct.t should never change by the client. All processes available in this module read only the content.

By lazy, we mean that we don't try to make an OCaml value which contains all binded values available in the IDX file - and, by this way, we don't process entirely the file. We read values only when the client ask to get these values - call by need. Use this decoder with the syscall mmap to get the expected Cstruct.t could be useful when mmap do a lazy read.

Parameters

module Hash : sig ... end

Signature

type error =
  1. | Invalid_header of string
    (*

    Appear when the header of the IDX file is incorrect.

    *)
  2. | Invalid_version of int32
    (*

    Appear when the version of the IDX file is wrong.

    *)
  3. | Invalid_index
    (*

    Appear when we try to read an area outside the IDX file.

    *)
  4. | Expected_bigoffset_table
    (*

    Appear when we try to read a big offset table and we can't catch it.

    *)
  5. | Invalid_bigoffset_index of int
    (*

    Appear when we try to read a big offset value and we can't catch it.

    *)

The type error.

val pp_error : error Fmt.t

Pretty-printer of error.

type t

State of the IDX lzy decoder.

val make : ?cache:int -> Cstruct.t -> (t, error) Stdlib.result

Make a new state from a Cstruct.t buffer. You can specify how many elements we can store to the cache. This function returns the state t or an error.

Indeed, in this function we check if the IDX file stored entirely on the Cstruct.t is well-formed. Otherwise, we return an explicit error.

val find : t -> Hash.t -> (Checkseum.Crc32.t * int64) option

find t hash get the CRC-32 checksum and the absolute offset binded on hash in the IDX file represented by t only if hash exists. Otherwise, it returns None.

val mem : t -> Hash.t -> bool

mem t hash returns true if hash exists in the IDX file represented by t. Otherwise, it returns false.

val iter : t -> (Hash.t -> (Checkseum.Crc32.t * int64) -> unit) -> unit

Iteration in the IDX file.

val fold : t -> (Hash.t -> (Checkseum.Crc32.t * int64) -> 'a -> 'a) -> 'a -> 'a

Fold in the IDX file.

val cardinal : t -> int
OCaml

Innovation. Community. Security.