package biniou

  1. Overview
  2. Docs
Binary data format designed for speed, safety, ease of use and backward compatibility as protocols evolve

Install

dune-project
 Dependency

Authors

Maintainers

Sources

biniou-1.2.2.tbz
sha256=8bf3ff17cd0ecb2d6b6d1d94cb08ef089d44caef96e9bae6be6839d428fa318f
sha512=7d03b3759a3a2e1c77713aa1b8375a1f1917f49d14fe5e3cb01d5e53a12e6385b7a3b0f4827f3be71182c31c416d780e1f9ef011dc205cb8f9b0ab2d8fc23cfd

doc/biniou/Bi_stream/index.html

Module Bi_streamSource

Streaming utilities (experimental)

This module offers a streaming interface for representing long lists of elements that cannot fit in memory. Stream items are serialized as chunks of configurable length.

Stream format (independent from the biniou serialization format):

  ( ONE INT64 BYTE* )* ZERO

where INT64 is the length of a chunk (unsigned big-endian 64-bit int), i.e. the number of following BYTEs. ONE and ZERO are the single-byte representations of 1 and 0 and are used to indicate whether the end of the stream is reached.

Sourceval read_stream : (string -> 'a array) -> in_channel -> 'a Stream.t

read_stream of_string ic creates an OCaml stream from an input channel ic. The data come in chunks and each chunk is converted from a string to an array by calling of_string.

Sourceval write_stream : ?chunk_len:int -> ('a array -> string) -> out_channel -> 'a Stream.t -> unit

write_stream to_string oc st writes an OCaml stream to the output channel oc. It creates chunks of chunk_len, except for the last chunk which is usually smaller.

  • parameter chunk_len

    has a default value of 1024. The limit supported by this OCaml implementation on 32-bit platforms is 16777215.