Lines Matching defs: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
99 /// The impl provides static factory functions to create a QR Code from text or binary data.
105 /// - High level: Take the payload data and call `QrCode::encode_text()` or `QrCode::encode_binary()`.
108 /// - Low level: Custom-make the array of data codeword bytes (including segment
158 /// data is too long to fit in any version at the given ECC level.
165 /// Returns a QR Code representing the given binary data at the given error correction level.
172 /// data is too long to fit in any version at the given ECC level.
173 pub fn encode_binary(data: &[u8], ecl: QrCodeEcc) -> Result<Self,DataTooLong> {
174 let segs: [QrSegment; 1] = [QrSegment::make_bytes(data)];
191 /// data is too long to fit in any version at the given ECC level.
209 /// Returns a wrapped `QrCode` if successful, or `Err` if the data is too
220 let datacapacitybits: usize = QrCode::get_num_data_codewords(version, ecl) * 8; // Number of data bits available
224 } else if version >= maxversion { // All versions in the range could not fit the given data
234 // Increase the error correction level while the data still fits in the current version number
241 // Concatenate all segments to create the data bit string
246 bb.0.extend_from_slice(&seg.data);
259 // Pad with alternating bytes until data capacity is reached
281 /// error correction level, data codeword bytes, and mask number.
404 // Draw configuration data
416 let data: u32 = u32::from(self.errorcorrectionlevel.format_bits() << 3 | mask.value());
417 let mut rem: u32 = data;
421 (data << 10 | rem) ^ 0x5412 // uint15
457 let data = u32::from(self.version.value()); // uint6, in the range [7, 40]
458 let mut rem: u32 = data;
462 data << 12 | rem // uint18
514 // Returns a new byte string representing the given data with the appropriate error correction
516 fn add_ecc_and_interleave(&self, data: &[u8]) -> Vec<u8> {
519 assert_eq!(data.len(), QrCode::get_num_data_codewords(ver, ecl), "Illegal argument");
528 // Split data into blocks and append ECC to each block
534 let mut dat = data[k .. k+datlen].to_vec();
558 // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
559 // data area of this QR Code. Function modules need to be marked off before this is called.
560 fn draw_codewords(&mut self, data: &[u8]) {
561 assert_eq!(data.len(), QrCode::get_num_raw_data_modules(self.version) / 8, "Illegal argument");
563 let mut i: usize = 0; // Bit index into the data
575 if !self.isfunction[(y * self.size + x) as usize] && i < data.len() * 8 {
576 *self.module_mut(x, y) = get_bit(u32::from(data[i >> 3]), 7 - ((i as i32) & 7));
585 debug_assert_eq!(i, data.len() * 8);
715 // Returns the number of data bits that can be stored in a QR Code of the given version number, after
733 // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
776 // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
777 fn reed_solomon_compute_remainder(data: &[u8], divisor: &[u8]) -> Vec<u8> {
779 for b in data { // Polynomial division
937 /// A segment of character/binary/control data in a QR Code symbol.
941 /// The mid-level way to create a segment is to take the payload data
947 /// Even in the most favorable conditions, a QR Code can only hold 7089 characters of data.
955 // The length of this segment's unencoded data. Measured in characters for
957 // Not the same as the data's bit length. Accessed through num_chars().
960 // The data bits of this segment. Accessed through data().
961 data: Vec<bool>,
970 /// Returns a segment representing the given binary data encoded in byte mode.
975 pub fn make_bytes(data: &[u8]) -> Self {
976 let mut bb = BitBuffer(Vec::with_capacity(data.len() * 8));
977 for &b in data {
980 QrSegment::new(QrSegmentMode::Byte, data.len(), bb.0)
1078 /// Creates a new QR Code segment with the given attributes and data.
1082 pub fn new(mode: QrSegmentMode, numchars: usize, data: Vec<bool>) -> Self {
1083 Self { mode, numchars, data }
1101 /// Returns the data bits of this segment.
1102 pub fn data(&self) -> &Vec<bool> {
1103 &self.data
1123 result = result.checked_add(seg.data.len())?;
1156 /// Describes how a segment's data bits are interpreted.
1222 /// The error type when the supplied data does not fit any QR Code version.
1230 /// - Split the text data into better or optimal segments in order to reduce the number of bits required.
1231 /// - Change the text or binary data to be shorter.