Basic error correction working, but slow

This commit is contained in:
Cyryl Płotnicki 2021-05-16 10:39:22 +01:00
parent 6ba7045301
commit 4113a997d6
2 changed files with 1 additions and 8 deletions

View file

@ -4,7 +4,7 @@ use anyhow::*;
use reed_solomon::Encoder;
use reed_solomon::{Buffer, Decoder};
const BLOCK_SIZE: usize = 256;
const BLOCK_SIZE: usize = 64;
const ECC_LENGTH: usize = 8;
// TODO: make the API streaming friendly
@ -18,15 +18,12 @@ pub fn encode(bytes: &[u8]) -> Result<Vec<u8>> {
let mut result = vec![];
dbg!(encoded_blocks.len());
for buffer in encoded_blocks {
dbg!(buffer.bytes().count());
for byte in buffer.bytes() {
result.push(byte?);
}
}
dbg!(result.len());
Ok(result)
}
@ -39,15 +36,12 @@ pub fn decode(bytes: &[u8]) -> Result<Vec<u8>> {
let mut result = vec![];
dbg!(decoded_blocks.len());
for buffer in decoded_blocks {
dbg!(buffer.bytes().count());
for byte in buffer.data() {
result.push(byte.clone());
}
}
dbg!(result.len());
Ok(result)
}

View file

@ -13,7 +13,6 @@ mod must {
source.write_text_to_file("second", "some contents").unwrap();
source.write_text_to_file("third", "some other contents").unwrap();
dbg!("setup done");
assert_same_after_restore(source.path())
}