fn add_ecc_and_interleave(&self, data: &[u8]) -> Vec<u8> {
        let ver: Version = self.version;
        let ecl: QrCodeEcc = self.errorcorrectionlevel;
        assert_eq!(
            data.len(),
            QrCode::get_num_data_codewords(ver, ecl),
            "Illegal argument"
        );

        // Calculate parameter numbers
        let numblocks: usize = QrCode::table_get(&NUM_ERROR_CORRECTION_BLOCKS, ver, ecl);
        let blockecclen: usize = QrCode::table_get(&ECC_CODEWORDS_PER_BLOCK, ver, ecl);
        let rawcodewords: usize = QrCode::get_num_raw_data_modules(ver) / 8;
        let numshortblocks: usize = numblocks - rawcodewords % numblocks;
        let shortblocklen: usize = rawcodewords / numblocks;

        // Split data into blocks and append ECC to each block
        let mut blocks = Vec::<Vec<u8>>::with_capacity(numblocks);
        let rsdiv: Vec<u8> = QrCode::reed_solomon_compute_divisor(blockecclen);
        let mut k: usize = 0;
        for i in 0..numblocks {
            let datlen: usize = shortblocklen - blockecclen + usize::from(i >= numshortblocks);
            let mut dat = data[k..k + datlen].to_vec();
            k += datlen;
            let ecc: Vec<u8> = QrCode::reed_solomon_compute_remainder(&dat, &rsdiv);
            if i < numshortblocks {
                dat.push(0);
            }
            dat.extend_from_slice(&ecc);
            blocks.push(dat);
        }

        // Interleave (not concatenate) the bytes from every block into a single sequence
        let mut result = Vec::<u8>::with_capacity(rawcodewords);
        for i in 0..=shortblocklen {
            for (j, block) in blocks.iter().enumerate() {
                // Skip the padding byte in short blocks
                if i != shortblocklen - blockecclen || j >= numshortblocks {
                    result.push(block[i]);
                }
            }
        }
        result
    }
// Returns a new byte string representing the given data with the appropriate error correction
// codewords appended to it, based on this object's version and error correction level.
Returns a new byte string representing the given data with the appropriate error correction
codewords appended to it, based on this object's version and error correction level.
Returns a new byte string representing the given data with the appropriate error correction codewords appended to it based on this object ' s version and error correction level .
fn add_ecc_and_interleave(&self, data: &[u8]) -> Vec<u8> {
        let ver: Version = self.version;
        let ecl: QrCodeEcc = self.errorcorrectionlevel;
        assert_eq!(
            data.len(),
            QrCode::get_num_data_codewords(ver, ecl),
            "Illegal argument"
        );
        // Calculate parameter numbers
        let numblocks: usize = QrCode::table_get(&NUM_ERROR_CORRECTION_BLOCKS, ver, ecl);
        let blockecclen: usize = QrCode::table_get(&ECC_CODEWORDS_PER_BLOCK, ver, ecl);
        let rawcodewords: usize = QrCode::get_num_raw_data_modules(ver) / 8;
        let numshortblocks: usize = numblocks - rawcodewords % numblocks;
        let shortblocklen: usize = rawcodewords / numblocks;
        // Split data into blocks and append ECC to each block
        let mut blocks = Vec::<Vec<u8>>::with_capacity(numblocks);
        let rsdiv: Vec<u8> = QrCode::reed_solomon_compute_divisor(blockecclen);
        let mut k: usize = 0;
        for i in 0..numblocks {
            let datlen: usize = shortblocklen - blockecclen + usize::from(i >= numshortblocks);
            let mut dat = data[k..k + datlen].to_vec();
            k += datlen;
            let ecc: Vec<u8> = QrCode::reed_solomon_compute_remainder(&dat, &rsdiv);
            if i < numshortblocks {
                dat.push(0);
            }
            dat.extend_from_slice(&ecc);
            blocks.push(dat);
        }
        // Interleave (not concatenate) the bytes from every block into a single sequence
        let mut result = Vec::<u8>::with_capacity(rawcodewords);
        for i in 0..=shortblocklen {
            for (j, block) in blocks.iter().enumerate() {
                // Skip the padding byte in short blocks
                if i != shortblocklen - blockecclen || j >= numshortblocks {
                    result.push(block[i]);
                }
            }
        }
        result
    }
fn add_ecc_and_interleave ( & self , data : & [ u8 ] ) -> Vec < u8 > { let ver : Version = self . version ; let ecl : QrCodeEcc = self . errorcorrectionlevel ; assert_eq ! ( data len ( ) QrCode get_num_data_codewords ( ver ecl ) " " ) ; // Calculate parameter numbers let numblocks : usize = QrCode :: table_get ( & NUM_ERROR_CORRECTION_BLOCKS , ver , ecl ) ; let blockecclen : usize = QrCode :: table_get ( & ECC_CODEWORDS_PER_BLOCK , ver , ecl ) ; let rawcodewords : usize = QrCode :: get_num_raw_data_modules ( ver ) / 8 ; let numshortblocks : usize = numblocks - rawcodewords % numblocks ; let shortblocklen : usize = rawcodewords / numblocks ; // Split data into blocks and append ECC to each block let mut blocks = Vec :: < Vec < u8 > > :: with_capacity ( numblocks ) ; let rsdiv : Vec < u8 > = QrCode :: reed_solomon_compute_divisor ( blockecclen ) ; let mut k : usize = 0 ; for i in 0 .. numblocks { let datlen : usize = shortblocklen - blockecclen + usize :: from ( i >= numshortblocks ) ; let mut dat = data [ k .. k + datlen ] . to_vec ( ) ; k += datlen ; let ecc : Vec < u8 > = QrCode :: reed_solomon_compute_remainder ( & dat , & rsdiv ) ; if i < numshortblocks { dat . push ( 0 ) ; } dat . extend_from_slice ( & ecc ) ; blocks . push ( dat ) ; } // Interleave (not concatenate) the bytes from every block into a single sequence let mut result = Vec :: < u8 > :: with_capacity ( rawcodewords ) ; for i in 0 ..= shortblocklen { for ( j , block ) in blocks . iter ( ) . enumerate ( ) { // Skip the padding byte in short blocks if i != shortblocklen - blockecclen || j >= numshortblocks { result . push ( block [ i ] ) ; } } } result }
Returns a new byte string representing the given data with the appropriate error correction
codewords appended to it, based on this object's version and error correction level.
Returns a new byte string representing the given data with the appropriate error correction codewords appended to it based on this object ' s version and error correction level .
&self
data
&[u8]