pub(crate) fn add_chunk(
    out: &mut Vec<u8>,
    type_: &[u8; 4],
    data: &[u8],
) -> Result<(), Error> {
    let length = data.len();
    if length > (1 << 31) {
        return Err(Error(77));
    }
    let previous_length = out.len();
    out.reserve(length + 12);
    /*1: length*/
    lodepng_add32bit_int(out, length as u32);
    /*2: chunk name (4 letters)*/
    out.extend_from_slice(&type_[..]);
    /*3: the data*/
    out.extend_from_slice(data);
    /*4: CRC (of the chunkname characters and the data)*/
    lodepng_add32bit_int(out, 0);
    lodepng_chunk_generate_crc(&mut out[previous_length..]);
    Ok(())
}
/*chunk_name must be string of 4 characters*/
chunk_name must be string of 4 characters
chunk_name must be string of 4 characters
pub(crate) fn add_chunk(
    out: &mut Vec<u8>,
    type_: &[u8; 4],
    data: &[u8],
) -> Result<(), Error> {
    let length = data.len();
    if length > (1 << 31) {
        return Err(Error(77));
    }
    let previous_length = out.len();
    out.reserve(length + 12);
    /*1: length*/
    lodepng_add32bit_int(out, length as u32);
    /*2: chunk name (4 letters)*/
    out.extend_from_slice(&type_[..]);
    /*3: the data*/
    out.extend_from_slice(data);
    /*4: CRC (of the chunkname characters and the data)*/
    lodepng_add32bit_int(out, 0);
    lodepng_chunk_generate_crc(&mut out[previous_length..]);
    Ok(())
}
pub ( crate ) fn add_chunk ( out : & mut Vec < u8 > , type_ : & [ u8 ; 4 ] , data : & [ u8 ] , ) -> Result < ( ) , Error > { let length = data . len ( ) ; if length > ( 1 << 31 ) { return Err ( Error ( 77 ) ) ; } let previous_length = out . len ( ) ; out . reserve ( length + 12 ) ; /*1: length*/ lodepng_add32bit_int ( out , length as u32 ) ; /*2: chunk name (4 letters)*/ out . extend_from_slice ( & type_ [ .. ] ) ; /*3: the data*/ out . extend_from_slice ( data ) ; /*4: CRC (of the chunkname characters and the data)*/ lodepng_add32bit_int ( out , 0 ) ; lodepng_chunk_generate_crc ( & mut out [ previous_length .. ] ) ; Ok ( ( ) ) }
chunk_name must be string of 4 characters
chunk_name must be string of 4 characters
out
&mut Vec<u8>
type_
&[u8; 4]
data
&[u8]