Decoder

Struct Decoder 

Source
pub struct Decoder { /* private fields */ }
Expand description

Decoder for the Luby transform

Implementations§

Source§

impl Decoder

Source

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
            }
        }
    }
}
Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.