[][src]Crate rqr

A small QR code generation project I made to dip my toes into rust again after several years of absence. I was always curious on how QR codes worked and it was a pretty good project to explore rust with. I followed an excellent tutorial.

This library supports strings encoded in numeric, alphanumeric and byte mode. It supports all versions, meaning different sizes, of a standard QR code with the different error correction levels.

QR code as string output

extern crate rqr;
use rqr::{Qr, StringRenderer};

fn main() {
    let qr = Qr::new("HELLO WORLD").unwrap();
    let s = StringRenderer::new().render(&qr);
    println!("{}", s);
}

SVG generation

use rqr::{Qr, SvgRenderer, Color, ECLevel};

fn main() {
    let qr = Qr::with_ecl("HELLO WORLD", ECLevel::Q).unwrap();
    let s = SvgRenderer::new()
        .light_module(Color::new(229, 189, 227))
        .dark_module(Color::new(119, 0, 0))
        .dimensions(200, 200)
        .render(&qr);
    println!("{}", s);
}

Override inferred settings

If not provided the version and encoding modes will be inferred to fit the encoded message. It's possible to override these and others:

use rqr::{QrBuilder, ECLevel, Version, Mask, Mode};

let qr = QrBuilder::new()
    .ecl(ECLevel::L)
    .version(Version::new(3))
    .mask(Mask::new(0))
    .mode(Mode::Alphanumeric)
    .into("1234567890")
    .unwrap();

More fine grained control is provided by the builder and the underlying matrix.

Re-exports

pub use builder::*;
pub use data::*;
pub use ec::*;
pub use info::*;
pub use mask::*;
pub use matrix::Module;
pub use matrix::Matrix;
pub use mode::Mode;
pub use qr::Qr;
pub use render::*;
pub use version::Version;

Modules

builder

QR code builder.

data

Data encoding.

ec

Error correction calculations.

info

Contains various QR specific encoding info.

mask

Masking flips data modules with certain patterns.

matrix

The matrix holds all modules in a QR code.

mode

Encoding modes for a QR code.

qr

Provides a simple and safe API.

render

Renders the QR code to different outputs.

version

Specifies the version of a QR code.