Native NIF module providing Rust-based compression implementations.
This module loads precompiled NIF binaries for Zstd, LZ4, Snappy, Bzip2,
and Blosc2 compression/decompression via RustlerPrecompiled. If a precompiled
artifact is not available for the current platform, it falls back to compiling
the Rust NIF from source (requires the Rust toolchain).
If the NIF fails to load entirely, all functions fall back to
:erlang.nif_error(:nif_not_loaded), and codecs are registered as unavailable
at startup.
Note: This module is excluded from coverage because all functions are Rustler NIF stubs that are replaced at load time by the native implementation.
Summary
Functions
Returns true when the native NIF library is loaded.
Functions
@spec nif_loaded?() :: boolean()
Returns true when the native NIF library is loaded.
The check calls the native codec_versions/0 function and verifies that it
returns a map. This function is primarily useful for startup diagnostics;
public compression calls already convert an unavailable NIF into
%ExCodecs.Error{reason: :nif_not_loaded}.
Arguments
This function takes no arguments.
Returns
truewhen the native library responds with its codec-version map.falsewhen the NIF stub raisesErlangErrororArgumentError.
Raises
Expected NIF-loading errors are caught. An exception of another class raised by the native implementation is not caught and propagates to the caller.
Example
iex> loaded? = ExCodecs.Native.nif_loaded?()
iex> is_boolean(loaded?)
true