package ezgzip

  1. Overview
  2. Docs
On This Page
  1. gzip compression
Legend:
Library
Module
Module type
Parameter
Class
Class type

gzip compression

type error =
  1. | Truncated of string
    (*

    Extracted size is greater than the allowed maximum size

    *)
  2. | Invalid_format
    (*

    Invalid data format

    *)
  3. | Compression_error of string
    (*

    zlib error

    *)
  4. | Size of {
    1. got : int;
    2. expected : int;
    }
    (*

    Extracted size does not match what was expected based on the source metadata

    *)
  5. | Checksum
    (*

    Extracted content checksum does not match what was expected based on the source metadata

    *)

Possible error cases

val compress : ?level:int -> string -> string

compress src returns a gzip-compressed version of src.

  • parameter level

    can use used to set the compression level from 0 (no compression) to 9 (highest compression).

  • raises Invalid_argument

    if level is outside of the range 0 to 9.

val decompress : ?ignore_size:bool -> ?ignore_checksum:bool -> ?max_size:int -> string -> (string, [> `Gzip of error ]) Stdlib.result

decompress src decompresses the content from the gzip-compressed src.

  • parameter ignore_size

    may be set to true if you want to ignore the expected decompressed size information in the gzip footer. Defaults to false.

  • parameter ignore_checksum

    may be set to true if you want to ignore the expected decompressed data checksum in the gzip footer. Defaults to false.

  • parameter max_size

    may be used to specify the maximum number of bytes to decompress. Defaults to Sys.max_string_length. If src decompresses to more than max_size bytes then this function will return Error (`Gzip (Truncated truncated_content)) containing the content which was decompressed.

  • returns

    Ok content if the decompression was successful

  • returns

    Error err if there was a problem during decompression

val pp_error : Stdlib.Format.formatter -> error -> unit
val pp_gzip_error : Stdlib.Format.formatter -> [ `Gzip of error ] -> unit
module Z : sig ... end
OCaml

Innovation. Community. Security.