feat: add reed-solomon
This commit is contained in:
32
README.md
32
README.md
@@ -8,7 +8,10 @@ Project or files:
|
|||||||
├── README_2.md
|
├── README_2.md
|
||||||
├── __concurrent
|
├── __concurrent
|
||||||
│ ├── arc-swap
|
│ ├── arc-swap
|
||||||
│ └── green-threads
|
│ ├── crossbeam_n_parking_lot
|
||||||
|
│ ├── glommio
|
||||||
|
│ ├── green-threads
|
||||||
|
│ └── rayon
|
||||||
├── __cpu
|
├── __cpu
|
||||||
│ └── x86
|
│ └── x86
|
||||||
├── __crypto
|
├── __crypto
|
||||||
@@ -22,13 +25,17 @@ Project or files:
|
|||||||
│ ├── ring
|
│ ├── ring
|
||||||
│ ├── rsa
|
│ ├── rsa
|
||||||
│ ├── secp256k1
|
│ ├── secp256k1
|
||||||
|
│ ├── simple_contract
|
||||||
│ ├── ssh-keys
|
│ ├── ssh-keys
|
||||||
│ └── totp
|
│ └── totp
|
||||||
├── __database
|
├── __database
|
||||||
|
│ ├── barrel
|
||||||
|
│ ├── gluesql
|
||||||
│ ├── persy
|
│ ├── persy
|
||||||
│ ├── rocksdb
|
│ ├── rocksdb
|
||||||
│ ├── rusqlite
|
│ ├── rusqlite
|
||||||
│ └── sled
|
│ ├── sled
|
||||||
|
│ └── sqlparser
|
||||||
├── __diff
|
├── __diff
|
||||||
│ ├── diffy
|
│ ├── diffy
|
||||||
│ └── prettydiff
|
│ └── prettydiff
|
||||||
@@ -38,12 +45,16 @@ Project or files:
|
|||||||
│ ├── err_derive
|
│ ├── err_derive
|
||||||
│ └── quick_error
|
│ └── quick_error
|
||||||
├── __ffi
|
├── __ffi
|
||||||
|
│ ├── abi_stable_crates
|
||||||
│ ├── c
|
│ ├── c
|
||||||
|
│ ├── c2
|
||||||
│ ├── c_export
|
│ ├── c_export
|
||||||
│ ├── c_layout
|
│ ├── c_layout
|
||||||
│ ├── cpp
|
│ ├── cpp
|
||||||
|
│ ├── dotalib
|
||||||
│ ├── jni
|
│ ├── jni
|
||||||
│ └── live-reload-rust
|
│ ├── live-reload-rust
|
||||||
|
│ └── rust_link_a
|
||||||
├── __fs
|
├── __fs
|
||||||
│ └── fuse
|
│ └── fuse
|
||||||
├── __gui
|
├── __gui
|
||||||
@@ -52,6 +63,7 @@ Project or files:
|
|||||||
│ ├── plotters
|
│ ├── plotters
|
||||||
│ └── svg
|
│ └── svg
|
||||||
├── __lang
|
├── __lang
|
||||||
|
│ ├── boa
|
||||||
│ ├── peg
|
│ ├── peg
|
||||||
│ ├── pest
|
│ ├── pest
|
||||||
│ ├── quickjs
|
│ ├── quickjs
|
||||||
@@ -62,6 +74,7 @@ Project or files:
|
|||||||
│ ├── sysinfo
|
│ ├── sysinfo
|
||||||
│ └── unixsocket
|
│ └── unixsocket
|
||||||
├── __log
|
├── __log
|
||||||
|
│ ├── fern
|
||||||
│ └── log4rs
|
│ └── log4rs
|
||||||
├── __machinelearning
|
├── __machinelearning
|
||||||
│ └── rusty-machine
|
│ └── rusty-machine
|
||||||
@@ -71,14 +84,17 @@ Project or files:
|
|||||||
│ ├── human_panic
|
│ ├── human_panic
|
||||||
│ ├── lazy_static
|
│ ├── lazy_static
|
||||||
│ ├── num_cpus
|
│ ├── num_cpus
|
||||||
|
│ ├── reed-solomon
|
||||||
│ ├── regex
|
│ ├── regex
|
||||||
│ ├── smartstring
|
│ ├── smartstring
|
||||||
|
│ ├── uint
|
||||||
│ └── walkdir
|
│ └── walkdir
|
||||||
├── __network
|
├── __network
|
||||||
│ ├── ip
|
│ ├── ip
|
||||||
│ ├── n_pcap
|
│ ├── n_pcap
|
||||||
│ ├── nfqueue
|
│ ├── nfqueue
|
||||||
│ ├── pcap
|
│ ├── pcap
|
||||||
|
│ ├── socket2
|
||||||
│ ├── tcp
|
│ ├── tcp
|
||||||
│ └── udp_laminar
|
│ └── udp_laminar
|
||||||
├── __performance
|
├── __performance
|
||||||
@@ -96,6 +112,8 @@ Project or files:
|
|||||||
│ ├── encoding
|
│ ├── encoding
|
||||||
│ ├── flatbuffers
|
│ ├── flatbuffers
|
||||||
│ ├── hjson
|
│ ├── hjson
|
||||||
|
│ ├── no_proto
|
||||||
|
│ ├── prost
|
||||||
│ └── serde_json
|
│ └── serde_json
|
||||||
├── __shell
|
├── __shell
|
||||||
│ ├── ssh2
|
│ ├── ssh2
|
||||||
@@ -107,11 +125,14 @@ Project or files:
|
|||||||
│ ├── ops
|
│ ├── ops
|
||||||
│ └── thread
|
│ └── thread
|
||||||
├── __template
|
├── __template
|
||||||
│ └── askama
|
│ ├── askama
|
||||||
|
│ └── handlebars-rust
|
||||||
├── __term
|
├── __term
|
||||||
│ ├── colored_msg
|
│ ├── colored_msg
|
||||||
│ ├── confy_table
|
│ ├── confy_table
|
||||||
│ ├── indicatif
|
│ ├── indicatif
|
||||||
|
│ ├── rustyline
|
||||||
|
│ ├── structopt
|
||||||
│ └── term
|
│ └── term
|
||||||
├── __time
|
├── __time
|
||||||
│ ├── chrono
|
│ ├── chrono
|
||||||
@@ -151,11 +172,12 @@ Project or files:
|
|||||||
├── ref_n_and.rs
|
├── ref_n_and.rs
|
||||||
├── sample.txt
|
├── sample.txt
|
||||||
├── slice.rs
|
├── slice.rs
|
||||||
|
├── string.rs
|
||||||
├── time.rs
|
├── time.rs
|
||||||
├── vec.rs
|
├── vec.rs
|
||||||
└── while.rs
|
└── while.rs
|
||||||
|
|
||||||
126 directories, 28 files
|
147 directories, 31 files
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
14
__misc/reed-solomon/Cargo.lock
generated
Normal file
14
__misc/reed-solomon/Cargo.lock
generated
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "reed-solomon"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"reed-solomon 0.2.1",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "reed-solomon"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "13de68c877a77f35885442ac72c8beb7c2f0b09380c43b734b9d63d1db69ee54"
|
||||||
11
__misc/reed-solomon/Cargo.toml
Normal file
11
__misc/reed-solomon/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[package]
|
||||||
|
name = "reed-solomon"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reed-solomon = "0.2.1"
|
||||||
|
|
||||||
36
__misc/reed-solomon/src/main.rs
Normal file
36
__misc/reed-solomon/src/main.rs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
use reed_solomon::Encoder;
|
||||||
|
use reed_solomon::Decoder;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let data = b"Hello World!";
|
||||||
|
|
||||||
|
// Length of error correction code
|
||||||
|
let ecc_len = 8;
|
||||||
|
|
||||||
|
// Create encoder and decoder with
|
||||||
|
let enc = Encoder::new(ecc_len);
|
||||||
|
let dec = Decoder::new(ecc_len);
|
||||||
|
|
||||||
|
// Encode data
|
||||||
|
let encoded = enc.encode(&data[..]);
|
||||||
|
|
||||||
|
// 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 = dec.correct(&mut corrupted, 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!("encoded: {:?}", encoded.data());
|
||||||
|
println!("error correction code: {:?}", encoded.ecc());
|
||||||
|
println!("corrupted: {:?}", corrupted);
|
||||||
|
println!("repaired: {:?}", recv_str);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user