pub fn decode_blocks(
    data: &mut [&mut [u8]],
    coding: &mut [&mut [u8]],
    erasures: &[i32],
) -> Result<()> {
    if data.is_empty() {
        return Ok(());
    }
    let block_len = data[0].len();
    let matrix: Vec<i32> = get_matrix(coding.len() as i32, data.len() as i32, ERASURE_W);

    // generate coding pointers, blocks should be the same size
    let mut coding_arg: Vec<*mut u8> = Vec::new();
    for x in coding.iter_mut() {
        if x.len() != block_len {
            return Err(ErasureError::InvalidBlockSize);
        }
        coding_arg.push(x.as_mut_ptr());
    }

    // generate data pointers, blocks should be the same size
    let mut data_arg: Vec<*mut u8> = Vec::new();
    for x in data.iter_mut() {
        if x.len() != block_len {
            return Err(ErasureError::InvalidBlockSize);
        }
        data_arg.push(x.as_mut_ptr());
    }
    let ret = unsafe {
        jerasure_matrix_decode(
            data.len() as i32,
            coding.len() as i32,
            ERASURE_W,
            matrix.as_ptr(),
            0,
            erasures.as_ptr(),
            data_arg.as_ptr(),
            coding_arg.as_ptr(),
            data[0].len() as i32,
        )
    };
    trace!("jerasure_matrix_decode ret: {}", ret);
    for x in data[erasures[0] as usize][0..8].iter() {
        trace!("{} ", x)
    }
    trace!("");
    if ret < 0 {
        return Err(ErasureError::DecodeError);
    }
    Ok(())
}
// Recover data + coding blocks into data blocks
//   data: array of blocks to recover into
//   coding: arry of coding blocks
//   erasures: list of indices in data where blocks should be recovered
Recover data + coding blocks into data blocks
data: array of blocks to recover into
coding: arry of coding blocks
erasures: list of indices in data where blocks should be recovered
Recover data + coding blocks into data blocks data : array of blocks to recover into coding : arry of coding blocks erasures : list of indices in data where blocks should be recovered
pub fn decode_blocks(
    data: &mut [&mut [u8]],
    coding: &mut [&mut [u8]],
    erasures: &[i32],
) -> Result<()> {
    if data.is_empty() {
        return Ok(());
    }
    let block_len = data[0].len();
    let matrix: Vec<i32> = get_matrix(coding.len() as i32, data.len() as i32, ERASURE_W);
    // generate coding pointers, blocks should be the same size
    let mut coding_arg: Vec<*mut u8> = Vec::new();
    for x in coding.iter_mut() {
        if x.len() != block_len {
            return Err(ErasureError::InvalidBlockSize);
        }
        coding_arg.push(x.as_mut_ptr());
    }
    // generate data pointers, blocks should be the same size
    let mut data_arg: Vec<*mut u8> = Vec::new();
    for x in data.iter_mut() {
        if x.len() != block_len {
            return Err(ErasureError::InvalidBlockSize);
        }
        data_arg.push(x.as_mut_ptr());
    }
    let ret = unsafe {
        jerasure_matrix_decode(
            data.len() as i32,
            coding.len() as i32,
            ERASURE_W,
            matrix.as_ptr(),
            0,
            erasures.as_ptr(),
            data_arg.as_ptr(),
            coding_arg.as_ptr(),
            data[0].len() as i32,
        )
    };
    trace!("jerasure_matrix_decode ret: {}", ret);
    for x in data[erasures[0] as usize][0..8].iter() {
        trace!("{} ", x)
    }
    trace!("");
    if ret < 0 {
        return Err(ErasureError::DecodeError);
    }
    Ok(())
}
pub fn decode_blocks ( data : & mut [ & mut [ u8 ] ] , coding : & mut [ & mut [ u8 ] ] , erasures : & [ i32 ] , ) -> Result < ( ) > { if data . is_empty ( ) { return Ok ( ( ) ) ; } let block_len = data [ 0 ] . len ( ) ; let matrix : Vec < i32 > = get_matrix ( coding . len ( ) as i32 , data . len ( ) as i32 , ERASURE_W ) ; // generate coding pointers, blocks should be the same size let mut coding_arg : Vec < * mut u8 > = Vec :: new ( ) ; for x in coding . iter_mut ( ) { if x . len ( ) != block_len { return Err ( ErasureError :: InvalidBlockSize ) ; } coding_arg . push ( x . as_mut_ptr ( ) ) ; } // generate data pointers, blocks should be the same size let mut data_arg : Vec < * mut u8 > = Vec :: new ( ) ; for x in data . iter_mut ( ) { if x . len ( ) != block_len { return Err ( ErasureError :: InvalidBlockSize ) ; } data_arg . push ( x . as_mut_ptr ( ) ) ; } let ret = unsafe { jerasure_matrix_decode ( data . len ( ) as i32 , coding . len ( ) as i32 , ERASURE_W , matrix . as_ptr ( ) , 0 , erasures . as_ptr ( ) , data_arg . as_ptr ( ) , coding_arg . as_ptr ( ) , data [ 0 ] . len ( ) as i32 , ) } ; trace ! ( " " ret ) ; for x in data [ erasures [ 0 ] as usize ] [ 0 .. 8 ] . iter ( ) { trace ! ( " " x ) } trace ! ( " " ) ; if ret < 0 { return Err ( ErasureError :: DecodeError ) ; } Ok ( ( ) ) }
Recover data + coding blocks into data blocks
data: array of blocks to recover into
coding: arry of coding blocks
erasures: list of indices in data where blocks should be recovered
Recover data + coding blocks into data blocks data : array of blocks to recover into coding : arry of coding blocks erasures : list of indices in data where blocks should be recovered
data
&mut [&mut [u8]]
coding
&mut [&mut [u8]]
erasures
&[i32]
data
&mut [&mut [u8]]
coding
&mut [&mut [u8]]
erasures
&[i32]