module F : sig ... endFrequencies module.
The state of the deflate algorithm. 'i and 'o are the implementation used respectively for the input and the ouput, see Buffer.st and Buffer.bs. The typer considers than 'i = 'o.
val pp_error : Stdlib.Format.formatter -> error -> unitPretty-printer of deflate error.
val pp : Stdlib.Format.formatter -> ('i, 'o) t -> unitPretty-printer of deflate state.
get_frequencies t returns the current frequencies of the deflate state. See F.t.
set_frequencies f t replaces the frequencies of the state t by f. The paranoid mode (if paranoid = true) checks if the frequencies can be used with the internal Hunk.t list. That means, for all characters and patterns (see Hunk.t), the binding frequencie must be > 0 (however, this check takes a long time).
eg. if we have a Literal 'a', (fst f).(Char.code 'a') > 0.
finish t means all input was sended. t will produce a new zlib block with the final flag and write the checksum of the input stream.
no_flush off len t means to continue the compression of an input at off on len byte(s).
partial_flush off len t finishes the current block, then the encoder writes a fixed empty block. So, the output is not aligned. We keep the current frequencies to compute the new Huffman tree for the new next block.
sync_flush off len t finishes the current block, then the encoder writes a stored empty block and the output is aligned. We keep the current frequencies to compute the new Huffman tree for the new next block.
full_flush off len t finishes the current block, then the encoder writes a stored empty block and the output is aligned. We delete the current frequencies to compute a new frequencies from your input and write a new Huffman tree for the new next block.
flush_of_meth meth returns the function depending to the method. Like, flush_of_meth SYNC returns sync_flush. It's a convenience function, nothing else.
flush off len t allows the state t to use an output at off on len byte(s).
val eval : 'a -> 'a -> ('a, 'a) t -> [ `Await of ('a, 'a) t | `Flush of ('a, 'a) t | `End of ('a, 'a) t | `Error of ('a, 'a) t * error ]eval i o t computes the state t with the input i and the ouput o. This function returns:
val used_in : ('i, 'o) t -> intused_in t returns how many byte(s) was used by t in the input.
val used_out : ('i, 'o) t -> intused_out t returns how many byte(s) was used by t in the output.
val bits_remaining : ('x, 'x) t -> intdefault ~witness ?wbits level makes a new state t. ~witness is an 'a Buffer.t specialized with an implementation (see Buffer.bytes or Buffer.bigstring) to informs the state wich implementation you use.
?wbits (by default, wbits = 15) it's the size of the window used by the Lz77 algorithm (see Lz77.default).
?meth can be specified to flush the internal buffer of the compression and create a new zlib block at n bytes specified.
level is level compression:
- 0: a stored compression (no compression)
- 1 .. 3: a fixed compression (compression with a static huffman tree)
- 4 .. 9: a dynamic compression (compression with a canonic huffman tree produced by the input)
val to_result : 'a -> 'a -> ?meth:(meth * int) -> ('a -> int option -> int) -> ('a -> int -> int) -> ('a, 'a) t -> (('a, 'a) t, error) Stdlib.resultto_result i o refill flush t is a convenience function to apply the deflate algorithm on the stream refill and call flush when the internal output is full (and need to flush).
If the compute catch an error, we returns Error exn (see DEFLATE.error). Otherwise, we returns the useless state t.
val bytes : Stdlib.Bytes.t -> Stdlib.Bytes.t -> ?meth:(meth * int) -> (Stdlib.Bytes.t -> int option -> int) -> (Stdlib.Bytes.t -> int -> int) -> (Stdlib.Bytes.t, Stdlib.Bytes.t) t -> ((Stdlib.Bytes.t, Stdlib.Bytes.t) t, error) Stdlib.resultSpecialization of to_result with Buffer.Bytes.t.
val bigstring : Buffer.Bigstring.t -> Buffer.Bigstring.t -> ?meth:(meth * int) -> (Buffer.Bigstring.t -> int option -> int) -> (Buffer.Bigstring.t -> int -> int) -> (Buffer.Bigstring.t, Buffer.Bigstring.t) t -> ((Buffer.Bigstring.t, Buffer.Bigstring.t) t, error) Stdlib.resultSpecialization of to_result with Buffer.Bigstring.t.