Crates.io | reed-solomon-32 |
lib.rs | reed-solomon-32 |
version | 2.0.2 |
source | src |
created_at | 2021-11-03 05:28:33.242267 |
updated_at | 2021-12-06 17:25:22.465363 |
description | Reed-Solomon BCH encoder and decoder with support of no_std environment |
homepage | |
repository | https://github.com/DaGenix/reed-solomon-32 |
max_upload_size | |
id | 476007 |
size | 78,293 |
Reed-Solomon BCH encoder and decoder implemented in Rust.
This is a port of python implementation from Wikiversity
This is a fork of https://github.com/mersinvald/reed-solomon-rs - the primary change being that it operates in GF(2^5) instead of GF(2^8) and that the public API has been modified.
[dependencies]
reed-solomon-32 = "^2.0.0"
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);
}