pub struct Decoder { /* private fields */ }Expand description
Decoder for the Luby transform
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn new(len: usize, blocksize: usize) -> Decoder
pub fn new(len: usize, blocksize: usize) -> Decoder
Creates a new Decoder for LT codes
§Example
extern crate rand;
extern crate fountaincode;
fn main() {
use fountaincode::ltcode::{Encoder, EncoderType, Decoder};
use fountaincode::ltcode::CatchResult::*;
use self::rand::{thread_rng, Rng};
let s:String = thread_rng().gen_ascii_chars().take(1_024).collect();
let buf = s.into_bytes();
let to_compare = buf.clone();
let length = buf.len();
let mut enc = Encoder::new(buf, 64, EncoderType::Random);
let mut dec = Decoder::new(length, 64);
for drop in enc {
match dec.catch(drop) {
Missing(stats) => {
println!("Missing blocks {:?}", stats);
}
Finished(data, stats) => {
for i in 0..length {
assert_eq!(to_compare[i], data[i]);
}
println!("Finished, stas: {:?}", stats);
//write data to disk??
return
}
}
}
}Sourcepub fn catch(&mut self, drop: Droplet) -> CatchResult
pub fn catch(&mut self, drop: Droplet) -> CatchResult
Catches a Droplet When it is possible to reconstruct a set, the bytes are returned
Auto Trait Implementations§
impl Freeze for Decoder
impl !RefUnwindSafe for Decoder
impl !Send for Decoder
impl !Sync for Decoder
impl Unpin for Decoder
impl !UnwindSafe for Decoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more