package reparse

  1. Overview
  2. Docs

Makes a buffered INPUT module. Buffered input provide backtracking functionality in Reparse for those input that doesn't support random seeking, for eg. Unix socket descriptors, Lwt input channels, Lwt streams, etc.

Parameters

module Promise : PROMISE
module Input : BUFFERED_INPUT with type 'a promise = 'a Promise.t

Signature

type t

Represents the input.

type 'a promise = 'a Promise.t

Represents an input promise.

type input = Input.t
val create : input -> t
val trim_buffer : t -> pos:int -> unit promise

trim_buffer t ~pos removes data from the input buffer up till pos.

Note After the input buffer is trimmed the parser is unable to backtrack to pos less than pos.

val get_char : t -> pos:int -> [ `Char of char | `Eof ] promise
val get_char_unbuffered : t -> pos:int -> [ `Char of char | `Eof ] promise
val get_cstruct : t -> pos:int -> len:int -> [ `Cstruct of Cstruct.t | `Eof ] promise

get t ~pos ~len returns `String s where String.length s <= len or `Eof if EOI is reached.

val get_cstruct_unbuffered : t -> pos:int -> len:int -> [ `Cstruct of Cstruct.t | `Eof ] promise
val last_trimmed_pos : t -> int promise
val buffer_size : t -> int option promise