Current section

Files

Jump to
gzlib src gzlib.erl
Raw

src/gzlib.erl

-module(gzlib).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/gzlib.gleam").
-export([compress/1, compress_custom/2, uncompress/1, crc32/1, crc32_continue/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/gzlib.gleam", 7).
?DOC(
" Compress (deflate) data with the default compression level\n"
" of the platform - typically level 6 (out of a maximum of 9)\n"
" \n"
" Returns an error if the data is not byte-aligned.\n"
).
-spec compress(bitstring()) -> {ok, bitstring()} | {error, nil}.
compress(Data) ->
gzlib_ffi:compress(Data).
-file("src/gzlib.gleam", 17).
?DOC(
" Compress (deflate) data with a custom compression level.\n"
" \n"
" Compression level should be between 0 (no compression) and 9 (maximum compression).\n"
" \n"
" Returns an error if the data is not byte-aligned\n"
" or the compression level is out of range.\n"
).
-spec compress_custom(bitstring(), integer()) -> {ok, bitstring()} |
{error, nil}.
compress_custom(Data, Level) ->
gzlib_ffi:compress(Data, Level).
-file("src/gzlib.gleam", 28).
?DOC(
" Uncompress (inflate) data.\n"
" \n"
" Returns an error if the data does not contain the necessary zlib headers\n"
" or if the data is not byte-aligned.\n"
).
-spec uncompress(bitstring()) -> {ok, bitstring()} | {error, nil}.
uncompress(Data) ->
gzlib_ffi:uncompress(Data).
-file("src/gzlib.gleam", 35).
?DOC(
" Calculate the CRC checksum for the given data.\n"
" \n"
" Returns an error if the data is not byte-aligned.\n"
).
-spec crc32(bitstring()) -> {ok, integer()} | {error, nil}.
crc32(Data) ->
gzlib_ffi:crc32(Data).
-file("src/gzlib.gleam", 43).
?DOC(
" Combine an existing CRC checksum with the checksum of the given data.\n"
" \n"
" Returns an error if the existing CRC is not in the range 0 to 2^32\n"
" or if the data is not byte-aligned.\n"
).
-spec crc32_continue(integer(), bitstring()) -> {ok, integer()} | {error, nil}.
crc32_continue(Crc, Data) ->
gzlib_ffi:crc32(Crc, Data).