package decompress
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=51983d4497ccb27c253e7464b03d38544aad51e0e7d537e405f4df6954c27ab0
sha512=17c7e3dc79b7cedaf649c208874a50a810002c71d061c133239b9813a9dfe424ba303a968ba68c728862bb20ceaa23465097334bc16b819317390d01c2f91f89
doc/decompress.zl/Zl/Inf/index.html
Module Zl.InfSource
The type for decoders.
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).
decoder src ~o ~allocate is a decoder that inputs from src.
Output buffer.
zl, as de, uses o buffer as internal buffer to store output. We recommend to allocate an io_buffer_size buffer as output buffer. Then, dst_rem decoder tells you how many unused bytes remain in o.
Window.
ZLIB has a header to specify the window size needed to inflate a given input. When zl knows that, it calls allocate with a number bits so that 1 lsl bits is the size of the window. bits can not be larger than 15 nor lower than 8. allocate can be fun bits -> De.make_window ~bits or a previously allocated window. decoder will take the ownership on it!
Ownership in our case means that decode will mutate it in-place and expect it to remain unchanged between invocations.
decode d0 is:
`Await d1ifd0has a`Manualinput source and awaits for more input. The client must use asrcwithd1to provide it.`Flush d1if given output buffero(seedecoder) needs to be drained before work can be resumed. The client must useflushwithd1to completely flusho. Usuallyowill be full and consist fully of bytes that need to be copied from the buffer, but sometimes only the first part of the buffer is used. In those casesdst_remwill give you the amount of free/unused bytes remain ino. These should not be copied since their contents are not part of the output. Instead, the firstbigstring_length o - Inf.dst_rem d1bytes should be copied when flushingo.`Malformed errif given input is malformed.erris a human-readable error message.`End d1if given input notify end of flow.ois possibly not empty (it can be check withdst_rem).
reset d is a d in its original state, as it was initialized by decoder.
src d s j l provides d with l bytes to read, starting at j in s. This byte range is read by calls to decode with d until `Await is returned. To signal the end of input call the function with l = 0.
dst_rem d is how many unused bytes remain in the output buffer of d.
src_rem d is how many unprocessed bytes remain in the input buffer of d.