RSProtect (rs_protect v0.1.0)
View SourceReed-Solomon encoder/decoder wrapper using Rust NIF.
Wraps the reed-solomon
Rust crate to provide robust
error-correcting codes for binary data. This library is suitable for
transmitting binary packets over noisy links with optional parity.
Examples
iex> {:ok, codeword} = RSProtect.encode("hello", 4)
iex> {:ok, original} = RSProtect.correct(codeword, 4)
iex> original == "hello"
true
Summary
Functions
Decode/correct a binary codeword and attempts to correct up to N/2 errors.
Decode/Correct a binary codeword and attempts to correct up to N/2 errors.
Same as correct/2
, but returns the number of errors corrected.
Encodes a binary by appending N parity bytes for error correction.
Encodes a binary by appending N parity bytes for error correction. As encode/2, except that it only returns the parity bytes.
Check if a given codeword is corrupted (detectable by RS).
Functions
@spec correct(binary(), non_neg_integer(), [byte()]) :: {:ok, binary()} | {:error, any()}
Decode/correct a binary codeword and attempts to correct up to N/2 errors.
Parameters
codeword
: binary of data + parityparity_bytes
: number of parity bytes originally used- 'known_erasures': offsets of known erasures (optional)
Returns
{:ok, original_data}
on success:error
if the message cannot be corrected
Decode/Correct a binary codeword and attempts to correct up to N/2 errors.
Same as correct/2
, but returns the number of errors corrected.
Parameters
codeword
: binary of data + parityparity_bytes
: number of parity bytes originally used- 'known_erasures': offsets of known erasures (optional)
Returns
{:ok, original_data, err_count}
on success:error
if the message cannot be corrected
Encodes a binary by appending N parity bytes for error correction.
Parameters
data
: binary to encodeparity_bytes
: number of bytes to use as parity (must be >= 2)
Returns
{:ok, binary}
with appended parity:error
on failure
Encodes a binary by appending N parity bytes for error correction. As encode/2, except that it only returns the parity bytes.
Check if a given codeword is corrupted (detectable by RS).