package decompress

  1. Overview
  2. Docs
Implementation of Zlib and GZip in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

decompress-1.4.3.tbz
sha256=b22254ae5eb7747452267fc976a3a0ba408c5afdae0896cac4068b4d79ed5a3d
sha512=96f62147f4e0548bb7c4680c4f9d7492a2b4a9e15bc100447b16842e3d1b43ed902fdef03907e1416c174a0586428e515f2deef53ed04098a0443a535938dd6d

doc/decompress.de/De/Def/Ns/index.html

Module Def.NsSource

Sourcetype error = [
  1. | `Invalid_compression_level
  2. | `Unexpected_end_of_output
]

The type for deflation errors.

Sourceval pp_error : Format.formatter -> error -> unit

Pretty-printer for error.

Sourceval compress_bound : int -> int

compress_bound len returns a clue about how many bytes we need to store the result of the deflation of len bytes. It's a pessimistic calculation.

Sourceval deflate : ?level:int -> bigstring -> bigstring -> (int, [> error ]) result

deflate ~level src dst deflates the content of src into dst.

In case of sucess, it returns the bytes writen in an Ok result. In case of failure, it returns the error in an Error result. compress_bound can be used to determine how many bytes the user needs to allocate as the destination buffer when he wants to compress N bytes.

Here is an example of how to compress any inputs:

  val input : bigstring

  let len = De.Def.Ns.compress_bound (De.bigstring_length input) in
  let dst = De.bigstring_create len in
  De.Def.Ns.deflate ~level:4 input dst
OCaml

Innovation. Community. Security.