View Source NimbleLZ4 (NimbleLZ4 v1.1.0)

LZ4 compression and decompression.

This functionality is built on top of native (Rust) NIFs. There is no streaming functionality, everything is done in memory.

Uncompressed Size

decompress/2 takes the original uncompressed size as a parameter. For this reason, it's common to store compressed binaries prefixed by their uncompressed length. For example, you could store the compressed binary as:

my_binary = <<...>>
store(<<byte_size(my_binary)::32>> <> NimbleLZ4.compress(my_binary))

When decompressing, you can extract the uncompressed length:

<<uncompressed_size::32, compressed_binary::binary>> = retrieve_binary()
uncompressed_binary = NimbleLZ4.decompress(compressed_binary, uncompressed_size)

Summary

Functions

Compresses the given binary.

Compresses the given binary using the LZ4 frame format into a frame.

Decompresses the given binary using the size of the uncompressed binary.

Decompresses the given frame binary using the LZ4 frame format.

Functions

Link to this function

compress(binary)

View Source (since 0.1.0)
@spec compress(binary()) :: binary()

Compresses the given binary.

Link to this function

compress_frame(binary)

View Source (since 1.1.0)
@spec compress_frame(binary()) :: binary()

Compresses the given binary using the LZ4 frame format into a frame.

Link to this function

decompress(binary, uncompressed_size)

View Source
@spec decompress(binary(), non_neg_integer()) :: {:ok, binary()} | {:error, term()}

Decompresses the given binary using the size of the uncompressed binary.

Link to this function

decompress_frame(binary)

View Source (since 1.1.0)
@spec decompress_frame(binary()) :: {:ok, binary()} | {:error, term()}

Decompresses the given frame binary using the LZ4 frame format.