Bytesrw_zstd
zstd
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
.
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.
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.
dict
is the decompression dictionary, if any.params
defaults to Dctx_params.default
slice_length
defaults to dstream_out_size
.r
and it has no constraints on its own use dstream_in_size
for its slices.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).val 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
w
's desire but if you get to create it and it has no constraints on its own use dstream_out_size
.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.
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.
dict
is the compression dictionary, if any.params
defaults to Cctx_params.default
.slice_length
defaults to cstream_out_size
.r
and it has no constraints on its own use cstream_in_size
for its slices.val 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
.w
's desire but if you get to create it and it has no constraints on its own use cstream_out_size
.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.
cstream_in_size ()
is the recommended length of input slices on compression.
cstream_out_size ()
is the recommended length of output slices on compression.
dstream_in_size ()
is the recommended length of input slices on decompression.