TUV
Pure-Rust QR and Micro QR code encoder with SVG, PNG, and terminal output.
TUV, for QRs
Install
[]
= "0.1.0"
Usage
High-level builder (primary API)
use ;
// UTF-8 string (byte mode — not Kanji mode)
let qr = from.generate?;
// Raw bytes (byte mode, non-UTF-8 OK)
let qr = from_bytes.with_ecc.generate?;
// Shift JIS Kanji mode (raw double-byte bytes, not UTF-8)
let qr = from_bytes.with_ecc.generate?;
// Normal or Micro QR version
let qr = from
.with_ecc
.with_version
.generate?;
// Micro QR with auto-selected smallest version
let qr = from_bytes
.with_micro
.with_ecc
.generate?;
// Backward-compatible render helpers
let svg = qr.to_svg;
let png = qr.to_png;
Render builder
let svg = qr.render
.dark_color
.light_color
.min_dimensions
.quiet_zone
.build_svg;
let terminal = qr.render.build_unicode;
let text = qr.render.dark_char.light_char.build_string;
let luma = qr.render.build_image_luma;
Low-level Bits API
use Bits;
use ;
let mut bits = new;
bits.push_eci_designator?;
bits.push_byte_data?;
bits.push_terminator?;
let qr = from_bits.with_ecc.generate?;
Matrix introspection
use Color;
let dark = qr == Dark;
let max_err = qr.max_allowed_errors;
let functional = qr.is_functional;
let debug = qr.to_debug_str;
Defaults
- When
with_eccis omitted, version and ECC are co-optimized for the smallest symbol (try each version from smallest upward, and at each version try ECC L → M → Q → H). - When
with_versionis set but ECC is omitted, the lowest ECC level that fits at that version is chosen. - When
with_eccis set but version is omitted, only version is auto-selected (unchanged). - Call
with_micro()to search Micro QR versions (v1–4) instead of Normal QR (v1–40). QRCode::from/ UTF-8 strings use byte mode. True Kanji mode requires Shift JIS bytes viafrom_bytesorBits::push_kanji_data.- Mask auto-selects the lowest-penalty pattern when
with_mask_idis omitted. - Micro QR uses a 2-module quiet zone; Normal QR uses 4.
CLI
An optional command-line tool lives in crates/tuv-cli:
Parity
Encoding and matrices are tested against qrcode 0.14.1 (dev-dependency). PIC output is intentionally excluded.
License
MIT