deflate, zlib and gzip streams for bytesrw, with a C and a pure OCaml backends

README.md

nox-zlib #

deflate (RFC 1951), zlib (RFC 1950) and gzip (RFC 1952) streams as bytesrw filters, with one implementation per target.

A program links nox-zlib and one of its two arms. nox-zlib.native, the default, binds the C zlib through bytesrw.zlib and is what a native build gets without asking. nox-zlib.portable is pure OCaml, exact on the 31-bit integers of wasm_of_ocaml, for the Solo5 and wasm links where the C library does not build; a cross arm names it beside nox-zlib. Both arms read and write the same streams, so a consumer never knows which one it runs on, except through Zlib.native.

The interface is Bytesrw_zlib's: Deflate, Zlib and Gzip, each with compress_reads, compress_writes, decompress_reads and decompress_writes, and Zlib.Error for a stream that is not one.

# let packed =
    Bytesrw.Bytes.Reader.filter_string [ Zlib.Gzip.compress_reads () ] "hello"
  in
  Bytesrw.Bytes.Reader.filter_string [ Zlib.Gzip.decompress_reads () ] packed;;
- : string = "hello"

Installation #

$ opam install nox-zlib

The portable arm checks its Adler-32 and CRC-32 through nox-crc, so the same stream decodes alike on 64-bit and on the 31-bit integers of a wasm link; test/wasm runs the suite under node when wasm-opt and node are installed.

License #

ISC. See LICENSE.md.