Module Bytesrw_zstd

zstd compressed streams.

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

type 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

module Dctx_params : sig ... end

Decompression parameters.

module Ddict : sig ... end

Decompression dictionaries.

val 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 and concatenates the result, until r returns Bytes.Slice.eod.
  • false this decompresses a single frame. Once the resulting reader returns 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).

The other parameters are:

val decompress_writes : ?dict:Ddict.t -> ?params:Dctx_params.t -> unit -> Bytesrw.Bytes.Writer.filter

decompress_writes () w filters the writes on w by decompressing sequences of zstd frames until Bytes.Slice.eod is written.

  • 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

module Cctx_params : sig ... end

Compression parameters.

module Cdict : sig ... end

Compression dictionaries.

val 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.

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

compress_writes () w filters the writes on w by compressing them to a single zstd frame until Bytes.Slice.eod is written.

  • 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

val version : unit -> string

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

val min_clevel : unit -> Cctx_params.clevel

min_clevel () is the minimum negative compression level allowed.

val max_clevel : unit -> Cctx_params.clevel

max_clevel () is the maximum compression level available.

val default_clevel : unit -> Cctx_params.clevel

default_clevel () is the default compression level.

val cstream_in_size : unit -> int

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

val cstream_out_size : unit -> int

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

val dstream_in_size : unit -> int

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

val dstream_out_size : unit -> int

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