package decompress
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=aa2e842dc009bcddcbb5c0791f5dbeee2bda5a104ecc7681aa37ac42537e3121
sha512=58e2529fa93f4f671ffd0a69c3542e835868f8c72db9c62b48d207c31f3585101d4d314f7e5922b273c86609b00c87343987b03b568d3e69749d2c7f7fa4089b
doc/decompress.gz/Gz/Def/index.html
Module Gz.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 `Buffer or `Channel destination the client can safely discard `Flush case (with assert false).
The type for GZIP encoders.
val encoder :
src ->
dst ->
?ascii:bool ->
?hcrc:bool ->
?filename:string ->
?comment:string ->
mtime:int32 ->
os ->
q:De.Queue.t ->
w:De.Lz77.window ->
level:int ->
encoderencoder src dst ~mtime os ~q ~w ~level 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 que as large as output buffer.
Window.
GZIP needs a sliding window to operate the LZ77 compression. The window must be a 32k window (De.make_window with bits = 15). The allocated window can be re-used by an other inflation/deflation process - but it can not be re-used concurrently or cooperatively with another inflation/deflation process.
Level.
Current implementation of GZIP does not handle any compression level. However, the client must give a level between 0 and 9, inclusively, Otherwise, we raise an Invalid_argument.
Metadata.
Client is able to store some metadata such as:
mtimetime of last modification of the input.ososwhich did the compression.filenamefilename of the input (no limitation about length).commentan arbitrary payload (no limitation about length).asciiif encoding of contents is ASCII.hcrcif the client wants a checksum of the GZIP header.
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 e1ife0has a`Manualinput source and awaits for more input. The client must usesrcwithe1to provide it.`Flush e1ife0has a`Manualdestination and needs more output storage. The client must drain the buffer before resuming operation.`End e1ife0encoded all input. Output buffer is possibly not empty (it can be check withdst_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.