package decompress
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
sha256=822f125b46c87f4a902c334db8c86d4d5f33ebe978e93c40351a4d3269b95225
    
    
  sha512=9cb82615923a5fffc5c8dce1d9361a467e35e91092c25c98f5afda8f4226059c59eb695c55e63adf92d766c7747e15df186386bcaeb399497dd1ae5b024c09fa
    
    
  doc/decompress.zl/Zl/Def/index.html
Module Zl.DefSource
The type for input sources. With a `Manual source the client must provide input with src. With `String or `Channel source the client can safely discard `Await case (with assert false).
The type for output destinations. With a `Manual destination the client must provide output storage with dst. With `String or `Channel destination the client can safely discard `Flush case (with assert false).
The type for ZLIB encoders.
val encoder : 
  ?dynamic:bool ->
  q:De.Queue.t ->
  w:De.Lz77.window ->
  level:int ->
  src ->
  dst ->
  encoderencoder ~q ~w ~level src dst is an encoder that inputs from src and that outputs to dst.
Internal queue.
encoder deals internally with compression algorithm and DEFLATE encoder. To pass compression values to DEFLATE encoder, we need a queue q. Length of q has an impact on performance, and small lengths can be a bottleneck, leading encode to emit many `Flush. We recommend a queue as large as output buffer.
Window.
ZLIB is able to constrain length of window used to do LZ77 compression. However, small window can slow-down LZ77 compression algorithm. Small windows are mostly used to enable inflation of output in memory-constrained environments, for example when compressed data from untrusted sources must be processed.
Level.
Zlib implements 10 levels (from 0 to 9). All of them use the dynamic & canonic huffman if dynamic is true (default). Otherwise, we use the static huffman. The higher the level, the better the ratio.
dst_rem e is how many unused bytes remain in the output buffer of e.
src e s j l provides e with l bytes to read, starting at j in s. This byte range is read by calls to encode with e until `Await is returned. To signal the end of input call the function with l = 0.
dst e s j l provides e with l bytes available to write, starting at j in s. This byte range is fill by calls to encode with e until `Flush is returned.
encode e0 is:
- `Await e1if- e0has a- `Manualinput source and awaits for more input. The client must use- srcwith- e1to provide it.
- `Flush e1if- e0has a- `Manualdestination and needs more output storage. The client must drain the buffer before resuming operation.
- `End e1if- e1encoded all input. Output buffer is possibly not empty (it can be check with- dst_rem).
Limitation.
The encoder must manipulate an output buffer of, at least, 2 bytes. If it's not the case, encode does nothing - and it tells you nothing more than it did nothing. Depending on what you do, a loop can infinitely call encode without any updates until the given output still has less than 2 bytes.