qrforge 0.1.1

A QR code generator written in Rust
Documentation
  • Coverage
  • 73.08%
    38 out of 52 items documented4 out of 23 items with examples
  • Size
  • Source code size: 130.22 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.63 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • J-a-c-c-o/qrforge
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • J-a-c-c-o

QRForge

QRForge is a QR code generator written in Rust. It supports generating QR codes in both raster (PNG) and vector (SVG) formats. The library provides a flexible builder pattern for creating QR codes with various parameters such as version, error correction level, and data segments.

Features

  • Generate QR codes in PNG and SVG formats
  • Support for different QR code versions and error correction levels
  • Structured append for splitting data across multiple QR codes
  • Optional parallel processing with Rayon

Installation

Add the following to your Cargo.toml:

[dependencies]

qrforge = "0.1.0"

To enable optional features:

[dependencies]

qrforge = { version = "0.1.0", features = ["image", "svg", "parallel"] }

Usage

Basic Usage

use qrforge::{QRCode, Mode, ErrorCorrection};

let qr = QRCode::builder()
    .add_segment(Some(Mode::Byte), b"Hello world")
    .error_correction(ErrorCorrection::L)
    .version(1.into())
    .build()
    .unwrap();

Generating a PNG Image

qr.image_builder()
    .set_width(200)
    .set_height(200)
    .set_border(4)
    .build_image_file("hello.png")
    .unwrap();

Generating an SVG Image

qr.svg_builder()
    .set_width(200)
    .set_height(200)
    .set_border(4)
    .build_svg_file("hello.svg")
    .unwrap();

Structured Append

let qr_codes = QRCode::builder()
    .add_segment(Some(Mode::Byte), b"I read the newspaper")
    .add_segment(Some(Mode::Numeric), b"1234567890")
    .error_correction(ErrorCorrection::L)
    .version(Version::V(1))
    .build_with_structual_append()
    .unwrap();

Examples

Examples can be found in the examples directory. To run an example, use the following command:

cargo run --example qrgen_image --features image

cargo run --example qrgen_svg --features svg

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.