package bytesrw

  1. Overview
  2. Docs
Composable byte stream readers and writers for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

bytesrw-0.4.1.tbz
sha512=9d4d65ff080a107f2ed35c4f13ac77c20e4920e92dffe84c270f23169d7db130506a450aa83a6c6c621ce80b699191291fb8be227d1fb47fb5fd49ddc150b37e

doc/bytesrw.zstd/Bytesrw_zstd/index.html

Module Bytesrw_zstdSource

zstd streams (via conf-zstd)

This module provides support for reading and writing zstd compressed streams with the libzstd C library.

Positions. The positions of readers and writers created by filters of this module default to 0.

Errors

Sourcetype Bytesrw.Bytes.Stream.error +=
  1. | Error of string

The type for zstd stream errors.

Except for the library parameters, all functions of this module and resulting reader and writers may raise Bytesrw.Bytes.Stream.Error with this error.

Decompress

Sourcemodule Dctx_params : sig ... end

Decompression parameters.

Sourcemodule Ddict : sig ... end

Decompression dictionaries.

Sourceval decompress_reads : ?all_frames:bool -> ?dict:Ddict.t -> ?params:Dctx_params.t -> unit -> Bytesrw.Bytes.Reader.filter

decompress_reads () r filters the reads of r by decompressing zstd frames.

If all_frames is:

  • true (default), this decompressses all frames until r returns Bytesrw.Bytes.Slice.eod and concatenates the result.
  • false this decompresses a single frame. Once the resulting reader returns Bytesrw.Bytes.Slice.eod, r is positioned exactly after the end of frame and can be used again to perform other non-filtered reads (e.g. a new zstd frame or other unrelated data).
Sourceval decompress_writes : ?dict:Ddict.t -> ?params:Dctx_params.t -> unit -> Bytesrw.Bytes.Writer.filter

decompress_writes () w ~eod filters the writes on w by decompressing sequences of zstd frames until Bytesrw.Bytes.Slice.eod is written. If eod is false the last Bytesrw.Bytes.Slice.eod is not written on w and at this point w can be used again to perform other non-filtered writes.

  • dict is the decompression dictionary, if any.
  • params defaults to Dctx_params.default
  • slice_length defaults to dstream_in_size
  • Compressed slice lengths abides to w's desire but if you get to create it and it has no constraints on its own use dstream_out_size.

Compress

Warning. The default Cctx_params.default compression parameters are those of the C library and do not perform checksums. If you want to compress so that the zstd command line tool can uncompress you need to checksum. See the example in the quick start.

Sourcemodule Cctx_params : sig ... end

Compression parameters.

Sourcemodule Cdict : sig ... end

Compression dictionaries.

Sourceval compress_reads : ?dict:Cdict.t -> ?params:Cctx_params.t -> unit -> Bytesrw.Bytes.Reader.filter

compress_reads () r filters the reads of r by compressing them to a single zstd frame.

Sourceval compress_writes : ?dict:Cdict.t -> ?params:Cctx_params.t -> unit -> Bytesrw.Bytes.Writer.filter

compress_writes () w ~eod filters the writes on w by compressing them to a single zstd frame until Bytesrw.Bytes.Slice.eod is written. If eod is false the last Bytesrw.Bytes.Slice.eod is not written on w and at this point w can be used again to perform non-filtered writes.

  • dict is the compression dictionary, if any.
  • params defaults to Cctx_params.default.
  • slice_length defaults to cstream_in_size.
  • Decompressed slice length abides to w's desire but if you get to create it and it has no constraints on its own use cstream_out_size.

Library parameters

Sourceval version : unit -> string

version () is the version of the libzstd C library.

Sourceval min_clevel : unit -> Cctx_params.clevel

min_clevel () is the minimum negative compression level allowed.

Sourceval max_clevel : unit -> Cctx_params.clevel

max_clevel () is the maximum compression level available.

Sourceval default_clevel : unit -> Cctx_params.clevel

default_clevel () is the default compression level.

Sourceval cstream_in_size : unit -> int

cstream_in_size () is the recommended length of input slices on compression.

Sourceval cstream_out_size : unit -> int

cstream_out_size () is the recommended length of output slices on compression.

Sourceval dstream_in_size : unit -> int

dstream_in_size () is the recommended length of input slices on decompression.

Sourceval dstream_out_size : unit -> int

dstream_out_size () is the recommended length of output slices on decompression.