1QR Code generator library - Rust, no heap 2========================================= 3 4 5Introduction 6------------ 7 8This project aims to be the best, clearest QR Code generator library. The primary goals are flexible options and absolute correctness. Secondary goals are compact implementation size and good documentation comments. 9 10Home page with live JavaScript demo, extensive descriptions, and competitor comparisons: https://www.nayuki.io/page/qr-code-generator-library 11 12 13Features 14-------- 15 16Core features: 17 18* Significantly shorter code but more documentation comments compared to competing libraries 19* Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard 20* Output format: Raw modules/pixels of the QR symbol 21* Detects finder-like penalty patterns more accurately than other implementations 22* Encodes numeric and special-alphanumeric text in less space than general text 23* Completely avoids heap allocation (e.g. `std::vec::Vec`), instead relying on suitably sized buffers from the caller and fixed-size stack allocations 24* Open-source code under the permissive MIT License 25 26Manual parameters: 27 28* User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data 29* User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one 30* User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number 31* User can create a list of data segments manually and add ECI segments 32 33More information about QR Code technology and this library's design can be found on the project home page. 34 35 36Examples 37-------- 38 39```rust 40extern crate qrcodegen; 41use qrcodegen::Mask; 42use qrcodegen::QrCode; 43use qrcodegen::QrCodeEcc; 44use qrcodegen::Version; 45 46// Text data 47let mut outbuffer = vec![0u8; Version::MAX.buffer_len()]; 48let mut tempbuffer = vec![0u8; Version::MAX.buffer_len()]; 49let qr = QrCode::encode_text("Hello, world!", 50 &mut tempbuffer, &mut outbuffer, QrCodeEcc::Medium, 51 Version::MIN, Version::MAX, None, true).unwrap(); 52let svg = to_svg_string(&qr, 4); // See qrcodegen-demo 53 54// Binary data 55let mut outbuffer = vec![0u8; Version::MAX.buffer_len()]; 56let mut dataandtemp = vec![0u8; Version::MAX.buffer_len()]; 57dataandtemp[0] = 0xE3; 58dataandtemp[1] = 0x81; 59dataandtemp[2] = 0x82; 60let qr = QrCode::encode_binary(&mut dataandtemp, 3, 61 &mut outbuffer, QrCodeEcc::High, 62 Version::new(2), Version::new(7), 63 Some(Mask::new(4)), false).unwrap(); 64for y in 0 .. qr.size() { 65 for x in 0 .. qr.size() { 66 (... paint qr.get_module(x, y) ...) 67 } 68} 69``` 70 71More complete set of examples: https://github.com/nayuki/QR-Code-generator/blob/master/rust-no-heap/examples/qrcodegen-demo.rs . 72