lz4_nif (lz4_nif v0.1.1)

View Source

Summary

Types

reserved for future use

Functions

Compress Binary using the LZ4 block format.

Same as compress/1 but accepts an options list.

Decompress an LZ4 block-format Binary whose original (uncompressed) size was OrigSize bytes.

Types

error_reason/0

-type error_reason() :: alloc_failed | badarg | compress_failed | decompress_failed.

option/0

-type option() :: term().

reserved for future use

Functions

compress(Binary)

-spec compress(binary()) -> {ok, binary()} | {error, error_reason()}.

Compress Binary using the LZ4 block format.

Returns {ok, Compressed} on success. Compressed does *not* include the original size; callers are expected to track it separately and pass it to uncompress/2.

compress(Binary, Options)

-spec compress(binary(), [option()]) -> {ok, binary()} | {error, error_reason()}.

Same as compress/1 but accepts an options list.

No options are currently interpreted. The two-arity form exists for API parity with szktty/erlang-lz4 so existing callers can migrate without rewriting.

uncompress(Binary, OrigSize)

-spec uncompress(binary(), non_neg_integer()) -> {ok, binary()} | {error, error_reason()}.

Decompress an LZ4 block-format Binary whose original (uncompressed) size was OrigSize bytes.

Returns {ok, Decompressed} on success. The result is an exact byte-match of the original input to compress/1,2. If the input is corrupt or OrigSize doesn't match, returns {error, decompress_failed}.