Module Obj_container_file.Decode

Decoding multiple rows from an input

type 'a t

Decoder for values of type 'a

val make : Input.t -> read:(Input.t -> 'a) -> 'a t

Decoder using the given input, and given row reading function.

val cur_block_remaining_count : _ t -> int

How many items remain in the current block (can be 0 at the beginning)

val next : 'a t -> 'a option

Read next row

High level API

val iter : 'a t -> f:('a -> unit) -> unit

Iterate on the elements. Can be done only once.

val fold : 'a t -> f:('b -> 'a -> 'b) -> init:'b -> 'b

Fold on the elements. Can be done only once.

val to_seq : 'a t -> 'a Stdlib.Seq.t

Obtain an ephemeral sequence of elements, that can be traversed only once.

val to_array_list : 'a t -> 'a array list

Obtain a list of arrays. Each array corresponds to a block of the input file. This is the most efficient way to get the whole file's content in memory in a stable form (unlike to_seq which is ephemeral).

  • since 0.2
val to_list : 'a t -> 'a list
val to_array : 'a t -> 'a array