reed-solomon-32

Crates.ioreed-solomon-32
lib.rsreed-solomon-32
version2.0.2
sourcesrc
created_at2021-11-03 05:28:33.242267
updated_at2021-12-06 17:25:22.465363
descriptionReed-Solomon BCH encoder and decoder with support of no_std environment
homepage
repositoryhttps://github.com/DaGenix/reed-solomon-32
max_upload_size
id476007
size78,293
(DaGenix)

documentation

https://docs.rs/reed-solomon-32/

README

Reed-Solomon BCH

Crates.io Documentation

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.

Setup

[dependencies]
reed-solomon-32 = "^2.0.0"

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);
}
Commit count: 73

cargo fmt