Module Eris_lwt.Decoder

This module provides a random-access decoder that can be used to efficiently decode pieces of content at given positions.

type t

Type of a decoder

val init : block_get:(ref -> block Lwt.t) -> Read_capability.t -> t

init ~block_get read_capability returns a new decoder.

Initializing a decoder will not cause any block de-references (the block_get function will not be called).

val pos : t -> int

pos decoder returns the position of the decoder as offset from the start of the encoded content.

val seek : int -> t -> t Lwt.t

seek pos decoder returns a new decoder that is positioned at pos.

val length : t -> int Lwt.t

length decoder returns the length of the encoded content.

val read : int -> t -> (string * t) Lwt.t

read n decoder reads at most n bytes of encoded content from position of decoder. Returns the decoded content as string as well as a new decoder with position set directly after end of content returned.