pub fn generate_coding_blocks(coding: &mut [&mut [u8]], data: &[&[u8]]) -> Result<()> {
    if data.is_empty() {
        return Ok(());
    }
    let k = data.len() as i32;
    let m = coding.len() as i32;
    let block_len = data[0].len() as i32;
    let matrix: Vec<i32> = get_matrix(m, k, ERASURE_W);
    let mut data_arg = Vec::with_capacity(data.len());
    for block in data {
        if block_len != block.len() as i32 {
            error!(
                "data block size incorrect {} expected {}",
                block.len(),
                block_len
            );
            return Err(ErasureError::InvalidBlockSize);
        }
        data_arg.push(block.as_ptr());
    }
    let mut coding_arg = Vec::with_capacity(coding.len());
    for mut block in coding {
        if block_len != block.len() as i32 {
            error!(
                "coding block size incorrect {} expected {}",
                block.len(),
                block_len
            );
            return Err(ErasureError::InvalidBlockSize);
        }
        coding_arg.push(block.as_mut_ptr());
    }

    unsafe {
        jerasure_matrix_encode(
            k,
            m,
            ERASURE_W,
            matrix.as_ptr(),
            data_arg.as_ptr(),
            coding_arg.as_ptr(),
            block_len,
        );
    }
    Ok(())
}
// Generate coding blocks into coding
//   There are some alignment restrictions, blocks should be aligned by 16 bytes
//   which means their size should be >= 16 bytes
Generate coding blocks into coding
There are some alignment restrictions, blocks should be aligned by 16 bytes
which means their size should be >= 16 bytes
Generate coding blocks into coding There are some alignment restrictions blocks should be aligned by 16 bytes which means their size should be > = 16 bytes
pub fn generate_coding_blocks(coding: &mut [&mut [u8]], data: &[&[u8]]) -> Result<()> {
    if data.is_empty() {
        return Ok(());
    }
    let k = data.len() as i32;
    let m = coding.len() as i32;
    let block_len = data[0].len() as i32;
    let matrix: Vec<i32> = get_matrix(m, k, ERASURE_W);
    let mut data_arg = Vec::with_capacity(data.len());
    for block in data {
        if block_len != block.len() as i32 {
            error!(
                "data block size incorrect {} expected {}",
                block.len(),
                block_len
            );
            return Err(ErasureError::InvalidBlockSize);
        }
        data_arg.push(block.as_ptr());
    }
    let mut coding_arg = Vec::with_capacity(coding.len());
    for mut block in coding {
        if block_len != block.len() as i32 {
            error!(
                "coding block size incorrect {} expected {}",
                block.len(),
                block_len
            );
            return Err(ErasureError::InvalidBlockSize);
        }
        coding_arg.push(block.as_mut_ptr());
    }
    unsafe {
        jerasure_matrix_encode(
            k,
            m,
            ERASURE_W,
            matrix.as_ptr(),
            data_arg.as_ptr(),
            coding_arg.as_ptr(),
            block_len,
        );
    }
    Ok(())
}
pub fn generate_coding_blocks ( coding : & mut [ & mut [ u8 ] ] , data : & [ & [ u8 ] ] ) -> Result < ( ) > { if data . is_empty ( ) { return Ok ( ( ) ) ; } let k = data . len ( ) as i32 ; let m = coding . len ( ) as i32 ; let block_len = data [ 0 ] . len ( ) as i32 ; let matrix : Vec < i32 > = get_matrix ( m , k , ERASURE_W ) ; let mut data_arg = Vec :: with_capacity ( data . len ( ) ) ; for block in data { if block_len != block . len ( ) as i32 { error ! ( " " block len ( ) block_len ) ; return Err ( ErasureError :: InvalidBlockSize ) ; } data_arg . push ( block . as_ptr ( ) ) ; } let mut coding_arg = Vec :: with_capacity ( coding . len ( ) ) ; for mut block in coding { if block_len != block . len ( ) as i32 { error ! ( " " block len ( ) block_len ) ; return Err ( ErasureError :: InvalidBlockSize ) ; } coding_arg . push ( block . as_mut_ptr ( ) ) ; } unsafe { jerasure_matrix_encode ( k , m , ERASURE_W , matrix . as_ptr ( ) , data_arg . as_ptr ( ) , coding_arg . as_ptr ( ) , block_len , ) ; } Ok ( ( ) ) }
Generate coding blocks into coding
There are some alignment restrictions, blocks should be aligned by 16 bytes
which means their size should be >= 16 bytes
Generate coding blocks into coding There are some alignment restrictions blocks should be aligned by 16 bytes which means their size should be > = 16 bytes
coding
&mut [&mut [u8]]
data
&[&[u8]]
coding
&mut [&mut [u8]]
data
&[&[u8]]