Module Maki.Ref

Reference to On-Disk Value
type 'a t = 'a Codec.t * hash

A reference to some value of type 'a, referred to by the hash of the value. The codec is there to deserialize the value when it's dereferenced.

val hash : _ t ‑> hash

Recover the hash corresponding to the reference.

val store : ?⁠storage:Maki__.Maki_storage.t ‑> ?⁠lifetime:Lifetime.t ‑> 'a Codec.t ‑> 'a ‑> 'a t or_error Lwt.t

store v x stores x on disk using v to encode it

val find : ?⁠storage:Maki__.Maki_storage.t ‑> 'a t ‑> 'a or_error Lwt.t

find codec h fetches the value whose hash is h, assuming it is stored, and decodes it. Returns an error if the value is not present.

val get : ?⁠storage:Maki__.Maki_storage.t ‑> 'a t ‑> 'a option or_error Lwt.t

get codec h fetches the value whose hash is h, if it is stored, and decodes it.