Crate fast_qr

Source
Expand description

§Easy to use fast QRCode generator

More examples can be found on GitHub.

§Converts QRCode to Unicode

use fast_qr::qr::QRBuilder;

// QRBuilder::new can fail if content is too big for version,
// please check before unwrapping.
let qrcode = QRBuilder::new("https://example.com/")
    .build()
    .unwrap();

let str = qrcode.to_str(); // .print() exists
println!("{}", str);

§Converts QRCode to SVG

use fast_qr::convert::{svg::SvgBuilder, Builder, Shape};
use fast_qr::qr::QRBuilder;

// QRBuilder::new can fail if content is too big for version,
// please check before unwrapping.
let qrcode = QRBuilder::new("https://example.com/")
    .build()
    .unwrap();

let _svg = SvgBuilder::default()
    .shape(Shape::RoundedSquare)
    .to_file(&qrcode, "out.svg");

§Converts QRCode to an image

use fast_qr::convert::{image::ImageBuilder, Builder, Shape};
use fast_qr::qr::QRBuilder;

// QRBuilder::new can fail if content is too big for version,
// please check before unwrapping.
let qrcode = QRBuilder::new("https://example.com/")
    .build()
    .unwrap();

let _img = ImageBuilder::default()
    .shape(Shape::RoundedSquare)
    .background_color([255, 255, 255, 0]) // transparency
    .fit_width(600)
    .to_file(&qrcode, "out.png");

Re-exports§

pub use crate::qr::QRBuilder;
pub use crate::qr::QRCode;

Modules§

convert
Converts a crate::QRCode to image or SVG you will need to activate associated feature flag
qr
Module qr is the entrypoint to start making QRCodes

Structs§

Module
Module is a single pixel in the QR code. Module uses u8 to store value and type.

Enums§

ECL
Error Correction Coding has 4 levels
Mask
The different mask patterns. The mask pattern should only be applied to the data and error correction portion of the QR code.
Mode
Enum for the 3 encoding mode
ModuleType
Module is a single pixel in the QR code.
Version
Enum containing all possible QRCode versions