package git

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

The functor to make the decoder module by a specific hash implementation. We constraint the Hash.S module to compute a

struct.t

flow. This module is a non-blocking decoder with a pure state of the IDX file. It's better to use this module instead Lazy if the client wants an OCaml representation of the IDX file - he can construct this specific OCaml value step by step with this decoder like a Radix tree.

In the result, if the client construct an efficient data-structure (like a Radix tree) when he decodes the IDX file, the find operation should be more fast than the Lazy.find. However, the Lazy.make operation could be more fast than to decode and to construct an OCaml value.

Parameters

module Hash : sig ... end

Signature

type error =
  1. | Invalid_byte of int
    (*

    Appear when we expect a specific byte and we catch another one.

    *)
  2. | Invalid_version of Stdlib.Int32.t
    (*

    Appear when the version of the IDX file is wrong.

    *)
  3. | Invalid_index_of_bigoffset of int
    (*

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

    *)
  4. | Expected_bigoffset_table
    (*

    Appear when we don't have a big offset table but expect one.

    *)
  5. | Invalid_hash of Hash.t * Hash.t
    (*

    Appear when the hash produced when we un-serialize the IDX file does not correspond with the hash provided.

    *)

The error type.

val pp_error : error Fmt.t

Pretty-printer of error.

type t

The decoder state.

val pp : t Fmt.t

Pretty-printer of the decoder t.

val make : unit -> t

Make a new decoder state t.

val refill : int -> int -> t -> t

refill off len t provides a new t with len bytes to read, starting at off. This byte range is read by calls to eval with t until `Await is returned.

val eval : Cstruct.t -> t -> [ `Await of t | `End of t * Hash.t | `Hash of t * (Hash.t * Checkseum.Crc32.t * int64) | `Error of t * error ]

eval src t is:

  • `Await t iff t needs more input storage. The client must use refill to provide a new buffer and then call eval with `Await until other value returned.
  • `End (t, hash) when t is done. We returns the hash of the IDX file.
  • `Hash (t, (hash, crc, offset)) when t can returns a new value (hash, crc, offset). The client can call eval to continue the process. The value will be consumed then.
  • `Error (t, exn) iff the decoder meet an error exn. The decoder can't continue and sticks in this situation.
OCaml

Innovation. Community. Security.