bytesrw-bz2#
Bzip2 compressed streams for bytesrw, using the libbz2 C library.
Overview#
Bytesrw_bz2 provides bytesrw reader and writer filters to compress and
decompress bzip2 streams, with the same filter shape as the
bytesrw.zlib and bytesrw.zstd libraries: decompress_reads,
decompress_writes, compress_reads, compress_writes. Concatenated
streams decode like the bzip2 tool handles appended files, and
single-stream mode leaves the wrapped reader positioned on the leftover
bytes.
Installation#
$ opam install bytesrw-bz2 # needs the libbz2 C library
If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install bytesrw-bz2
Usage#
# open Bytesrw;;
# let data = String.concat " " (List.init 100 string_of_int) in
let bz = Bytes.Reader.filter_string [ Bytesrw_bz2.compress_reads () ] data in
let back = Bytes.Reader.filter_string [ Bytesrw_bz2.decompress_reads () ] bz in
back = data && String.length bz < String.length data;;
- : bool = true
License#
ISC -- see LICENSE.md.