Read label images
Feed PNG, JPEG, WebP or GIF bytes through ImageInput::encoded(). A Code 128 label encoding STOCK-4827 returns that exact string.
crates.io
Rust 1.88+
1D + 2D
MIT
Decode 1D retail, warehouse and 2D matrix labels in process using the Rust crate powering QR Code AI’s scanner bindings.
Feed PNG, JPEG, WebP or GIF bytes through ImageInput::encoded(). A Code 128 label encoding STOCK-4827 returns that exact string.
Pass raw pixel buffers through ImageInput::rgba8() for camera streams or video pipelines without an image-encoding round trip.
Read each detection’s Symbology enum and content.text string so leading zeros survive, then query your own inventory database.
Add the crate with Cargo, filter barcode symbologies in process and return exact identifier strings.
Use Rust 1.88 or newer and add qrcode-barcode-scanner on crates.io to your Cargo project. Complete API docs are published on docs.rs.
The crate compiles the multi-format engine straight into your binary with no external CLI executable or remote lookup calls.
cargo add qrcode-barcode-scanner
Import the module in Rust source as qrcode_barcode_scanner (using underscores).
Default crate features enable all 16 barcode symbologies alongside QR Code, Micro QR and rMQR.
Create a Scanner with ScanProfile::Frame, supply encoded label bytes via ImageInput::encoded and keep the barcode symbologies your workflow needs. You can also set ScanConfig.formats so only chosen readers execute.
To prepare a reliable test label, create a Code 128 barcode with Barcode Generator containing STOCK-4827 and test the exported PNG.
use qrcode_barcode_scanner::{ImageInput, ScanProfile, Scanner, Symbology};
fn read_barcodes(path: &str) -> Result<Vec<(Symbology, String)>, Box<dyn std::error::Error>> {
let bytes = std::fs::read(path)?;
let scanner = Scanner::builder().profile(ScanProfile::Frame).build();
let report = scanner.scan(ImageInput::encoded(&bytes))?;
let items = report
.detections
.iter()
.filter(|d| d.symbology != Symbology::QrCode)
.map(|d| (d.symbology, d.content.text.clone()))
.collect();
Ok(items)
}
Move from ScanProfile::Frame to ScanProfile::Full when decoding low-contrast, tilted or worn label photos.
Verify report.trace.budget_exhausted == Some(false) before treating an empty detections list as final.
For a Code 128 label encoding STOCK-4827, read_barcodes returns (Symbology::Code128, "STOCK-4827"). A UPC-A code such as 012345678905 remains a String so its leading zero stays intact.
A blank image or QR-only photo yields Ok(vec![]). Unreadable files or oversized images return an Err whose err.code() identifies QRS-001 to QRS-006.
Sixteen barcode formats. Decodes EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode (ISBN maps to ean13, GS1-128 to code128, ITF-14 to itf).
Strings, geometry and budgets. Always retain decoded values as strings so leading zeros survive; linear barcodes can return endpoints instead of four corners. Set ScanConfig.formats to skip unused readers and pass None to budget_ms for unbounded scans.
Limits and licensing. Oversized uploads fail with QRS-002 or QRS-003, while invalid options (such as a zero Limits cap) fail up front with QRS-006. Current releases ship under the MIT licence (with Apache-2.0 notices in LICENSING.md); read the Rust crate README and Rust API guide.
Official crate guides, ScanReport schema specification and licensing notices.
Cargo setup, barcode formats, leading zeros, RGBA frames, error codes and licensing.
It is QR Code AI’s open-source MIT-licensed Rust crate (qrcode-barcode-scanner) for decoding 1D and 2D barcodes (and QR codes) straight in process. It powers every other language binding and returns a typed ScanReport with symbology, exact strings, raw bytes and measured geometry.
With default features enabled, it reads 16 barcode formats: EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode, along with QR Code, Micro QR and rMQR. ISBN, GS1-128 and ITF-14 report ean13, code128 and itf.
Rust 1.88 or newer is required, and yes, it can scan raw RGBA frames directly. Supply encoded PNG, JPEG, WebP or GIF bytes via ImageInput::encoded, or pass raw RGBA pixel buffers straight to ImageInput::rgba8 to skip image-encoding round trips.
No. The engine returns each encoded identifier, its Symbology and parsed GS1 payload fields when recognised. Keep identifiers as strings so leading zeros survive, and query your own catalogue or inventory database separately.
Yes. Set ScanConfig.formats to the symbologies you want; readers for other symbologies do not run, and report.trace.formats records the active filter. Leaving formats empty scans every compiled symbology.
When no barcode is detected, scanner.scan() returns Ok with an empty detections list (verify trace.budget_exhausted == Some(false) for a final result). Corrupt or oversized inputs, cancellation and invalid options return an Err carrying QRS-001 to QRS-006 on err.code().
Yes. Decoding runs 100% locally inside your Rust process with zero network requests, no QR Code AI account, no API key and no creation credits.
Yes. Current releases ship under the MIT licence, allowing commercial and proprietary products while keeping copyright and licence notices intact (see LICENSING.md for third-party Apache-2.0 notices). SDK usage is independent of QR Code AI’s paid creation plans and seven-day Premium trial.