Bytesrw_zlib.Gzip
gzip
streams.
Note. In general a gzip
stream can be made of multiple, independently compressed, members. The way the module handles gzip
member headers is described here.
val decompress_reads : ?all_members:bool -> unit -> Bytesrw.Bytes.Reader.filter
decompress_reads () r
filters the reads of r
by decompressing gzip
members. If all_members
is
true
(default), this concatenates decompressed sequences of gzip
members like gunzip
would do and errors if there is leftover data.false
this decompresses a single gzip
member. Once the resulting reader returns Bytesrw.Bytes.Slice.eod
, r
is positioned exactly after the end of the gzip member and can be used again to perform other non-filtered reads (e.g. a new gzip
member or other unrelated data).val decompress_writes : unit -> Bytesrw.Bytes.Writer.filter
decompress_writes () w ~eod
filters the writes on w
by decompressing sequences of gzip
members until Bytesrw.Bytes.Slice.eod
is written. If eod
is false
, the latter is not written on w
and at this point w
can be used again to perform other non-filtered writes.
val compress_reads : ?level:level -> unit -> Bytesrw.Bytes.Reader.filter
compress_reads ~level () r
filters the reads of r
by compressing them to as a single gzip
member at level level
(defaults to default_compression
).
val compress_writes : ?level:level -> unit -> Bytesrw.Bytes.Writer.filter
compress_writes ~level () w ~eod
filters the writes on w
by compressing them to a single gzip
member at level level
(defaults to default_compression
) until Bytesrw.Bytes.Slice.eod
is written. If eod
is false
the latter is not written on w
and at this point w
can be used again to perform other non-filtered writes.
Currently no facility is provided to access gzip
member headers. It seems those are little used in practice. However support is provided to read and write gzip
streams member-by-member which is used by certain formats.
On compression the member's header generated in the stream is zlib
's default header; see documentation of deflateSetHeader
in the the manual. Note that this watermarks the operating system in the stream (at least in v1.3.1 as of writing).