Lines Matching refs:data
47 //! - User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data
50 //! - User can create a list of data segments manually and add ECI segments
64 //! Text data:
74 //! Binary data:
104 /// The impl provides static factory functions to create a QR Code from text or binary data.
110 /// - High level: Take the payload data and call `QrCode::encode_text()` or `QrCode::encode_binary()`.
113 /// - Low level: Custom-make the array of data codeword bytes (including segment
136 /// If the data is too long to fit in any version in the given range
163 /// data capacities per version, ECC level, and text encoding mode.
192 /// Encodes the given binary data to a QR Code, returning a wrapped `QrCode` if successful.
193 /// If the data is too long to fit in any version in the given range
213 /// If successful, the resulting QR Code will use byte mode to encode the data.
219 /// data capacities per version, ECC level, and text encoding mode.
223 assert!(datalen <= dataandtempbuffer.len(), "Invalid data length");
260 let datacapacitybits: usize = QrCode::get_num_data_codewords(version, ecl) * 8; // Number of data bits available
264 } else if version >= maxversion { // All versions in the range could not fit the given data
274 // Increase the error correction level while the data still fits in the current version number
281 // Concatenate all segments to create the data bit string
288 let bit: u8 = (seg.data[i >> 3] >> (7 - (i & 7))) & 1;
301 // Pad with alternating bytes until data capacity is reached
315 /// error correction level, data codeword bytes, and mask number.
328 let (data, temp) = datacodewordsandoutbuffer.split_at_mut(datacodewordslen);
329 let allcodewords = Self::add_ecc_and_interleave(data, version, ecl, temp, tempbuffer);
440 // Appends error correction bytes to each block of the given data array, then interleaves
443 fn add_ecc_and_interleave<'b>(data: &[u8], ver: Version, ecl: QrCodeEcc, temp: &mut [u8], resultbuf: &'b mut [u8]) -> &'b [u8] {
444 assert_eq!(data.len(), QrCode::get_num_data_codewords(ver, ecl));
454 // Split data into blocks, calculate ECC, and interleave
457 let mut dat: &[u8] = data;
463 for j in 0 .. datlen { // Copy data
470 let mut k: usize = data.len() + i;
599 let data = u32::from(ecl.format_bits() << 3 | mask.value());
600 let mut rem: u32 = data;
604 (data << 10 | rem) ^ 0x5412 // uint15
641 /*---- Drawing data modules and masking ----*/
643 // Draws the raw codewords (including data and ECC) onto this QR Code. This requires the initial state of
645 fn draw_codewords(&mut self, data: &[u8]) {
646 assert_eq!(data.len(), QrCode::get_num_raw_data_modules(self.version()) / 8, "Illegal argument");
649 let mut i: usize = 0; // Bit index into the data
661 if !self.get_module_bounded(x, y) && i < data.len() * 8 {
662 self.set_module_bounded(x, y, get_bit(data[i >> 3].into(), 7 - ((i as u8) & 7)));
671 debug_assert_eq!(i, data.len() * 8);
812 // Returns the number of data bits that can be stored in a QR Code of the given version number, after
830 // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
903 // Returns the Reed-Solomon error correction codeword for the given data polynomial and this divisor polynomial.
904 fn compute_remainder(&self, data: &[u8], result: &mut [u8]) {
907 for b in data { // Polynomial division
1063 /// A segment of character/binary/control data in a QR Code symbol.
1067 /// The mid-level way to create a segment is to take the payload data
1073 /// Even in the most favorable conditions, a QR Code can only hold 7089 characters of data.
1080 // The length of this segment's unencoded data. Measured in characters for
1082 // Not the same as the data's bit length. Accessed through num_chars().
1085 // The data bits of this segment, packed in bitwise big endian.
1086 data: &'a [u8],
1088 // The number of valid data bits used in the buffer. Requires bitlength <= data.len() * 8.
1099 /// Returns a segment representing the given binary data encoded in byte mode.
1104 pub fn make_bytes(data: &'a [u8]) -> Self {
1105 QrSegment::new(QrSegmentMode::Byte, data.len(), data, data.len().checked_mul(8).unwrap())
1129 QrSegment::new(QrSegmentMode::Numeric, text.len(), bb.data, bb.length)
1157 QrSegment::new(QrSegmentMode::Alphanumeric, text.len(), bb.data, bb.length)
1176 QrSegment::new(QrSegmentMode::Eci, 0, bb.data, bb.length)
1182 /// Creates a new QR Code segment with the given attributes and data.
1186 pub fn new(mode: QrSegmentMode, numchars: usize, data: &'a [u8], bitlength: usize) -> Self {
1187 assert!(bitlength == 0 || (bitlength - 1) / 8 < data.len());
1188 Self { mode, numchars, data, bitlength }
1208 /// Returns the number of bytes needed for the data buffer of a segment
1215 /// An actual ECI segment can have shorter data. For non-ECI modes, the result is exact.
1222 // Returns the number of data bits needed to represent a segment
1227 // An actual ECI segment can have shorter data. For non-ECI modes, the result is exact.
1295 /// Describes how a segment's data bits are interpreted.
1345 data: &'a mut [u8],
1357 data: buffer,
1379 self.data[index] = bit << shift;
1381 self.data[index] |= bit << shift;
1393 /// The error type when the supplied data does not fit any QR Code version.
1399 /// - Split the text data into better or optimal segments in order to reduce the number of bits required.
1400 /// - Change the text or binary data to be shorter.