Crate reed_solomon_32[−][src]
Expand description
Reed-Solomon BCH encoder and decoder suitable for no_std
environment in GF(2^5).
This is a fork of https://github.com/mersinvald/reed-solomon-rs - the primary changes being that it operates in GF(2^5) instead of GF(2^8) and some significant revisions to the user facing API.
This library implements block encoder and decoder: error correction code is appended to original data.
Example
use reed_solomon_32::encode;
use reed_solomon_32::correct;
fn main() {
let data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
// Length of error correction code
let ecc_len = 8;
// Encode data
let encoded = encode(&data, ecc_len).unwrap();
// Simulate some transmission errors
let mut corrupted = *encoded;
for i in 0..4 {
corrupted[i] = 0x0;
}
// Try to recover data
let known_erasures = [0];
let recovered = correct(&mut corrupted, ecc_len, Some(&known_erasures)).unwrap();
let orig_str = std::str::from_utf8(&data).unwrap();
let recv_str = std::str::from_utf8(recovered.data()).unwrap();
println!("message: {:?}", orig_str);
println!("original data: {:?}", data);
println!("error correction code: {:?}", encoded.ecc());
println!("corrupted: {:?}", corrupted);
println!("repaired: {:?}", recv_str);
}
Modules
This is a specialized module and generally correct_err_count
,
correct
, and is_corrupted
functions
should be preferred.
Structs
Buffer for block encoded data
An error that indicates that a parameter that was supplied to a function was invalid for that function.
Enums
And error occurred while attempting to correct a message.
Functions
Decodes block-encoded message and returns Buffer
with corrected message and ecc offset.
Decodes block-encoded message and returns Buffer
with corrected message and ecc offset.
Also includes the number of errors corrected.
Encodes passed &[u8]
slice and returns Buffer
with result using
ecc
error correcting symbols.
Performs fast corruption check.