# qrcode-rs
A QR code and Micro QR code encoder library for Rust.
## Features
- **Standard QR Code** (Version 1-40) with all error correction levels (L, M, Q, H)
- **Micro QR Code** (Version M1-M4) for compact encoding
- **Multiple output formats**: PNG/JPEG (via `image` crate), SVG, EPS, PIC, HTML, PDF, Unicode, plain text
- **Automatic optimization**: selects the smallest version and optimal data mode segmentation
- **Customizable rendering**: colors, module dimensions, quiet zone, minimum/maximum size
- **2.0 workspace crates**: core, render, parse, decode, and individual renderer backends
- **Migration bridge**: `compat-1x` keeps the 1.x facade available while call sites move to 2.0 APIs
## Quick Start
```rust
use qrcode_rs::QrCode;
// Encode data into a QR code
let code = QrCode::new(b"https://example.com").unwrap();
// Render as a string
let string = code.render()
.dark_color('#')
.light_color(' ')
.build();
println!("{}", string);
// Render as an image (requires `image` feature)
// let image = code.render::<image::Luma<u8>>().build();
// image.save("qrcode.png").unwrap();
```
## Feature Flags
| `image` | Yes | PNG/JPEG rendering via the `image` crate |
| `svg` | Yes | SVG vector rendering |
| `eps` | Yes | Encapsulated PostScript rendering |
| `pic` | Yes | PIC (troff) rendering |
| `html` | Yes | HTML table / CSS Grid rendering |
| `pdf` | Yes | vector PDF rendering |
| `async` | No | Tokio-backed async rendering helpers |
| `decode-rqrr` | No | decoder adapter through `rqrr` |
| `compat-1x` | No | 1.x facade API during the 2.0 migration |
## Modules
- [`qrcode_rs::QrCode`](https://docs.rs/qrcode-rs/latest/qrcode_rs/struct.QrCode.html) — Main entry point for encoding
- [`qrcode_rs::bits`](https://docs.rs/qrcode-rs/latest/qrcode_rs/bits/index.html) — Bit-level data encoding
- [`qrcode_rs::canvas`](https://docs.rs/qrcode-rs/latest/qrcode_rs/canvas/index.html) — QR code canvas and masking
- [`qrcode_rs::ec`](https://docs.rs/qrcode-rs/latest/qrcode_rs/ec/index.html) — Reed-Solomon error correction
- [`qrcode_rs::optimize`](https://docs.rs/qrcode-rs/latest/qrcode_rs/optimize/index.html) — Data mode segmentation optimizer
- [`qrcode_rs::render`](https://docs.rs/qrcode-rs/latest/qrcode_rs/render/index.html) — Rendering pipeline and Pixel trait
- Split crates: `qrcode-core`, `qrcode-render`, `qrcode-parse`, `qrcode-decode`, `qrcode-svg`, `qrcode-eps`, `qrcode-pic`, `qrcode-html`, `qrcode-pdf`
## Migration
- [Migrating from qrcode-rs 1.x to 2.0](https://github.com/houseme/qrcode-rs/blob/main/MIGRATION-1.x-to-2.0.md)
## License
Licensed under either of [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) or [MIT License](https://opensource.org/licenses/MIT) at your option.