Rust Barcode Scanner SDK

Add offline 1D and 2D barcode scanning directly inside your Rust binary or service. Install the MIT-licensed core crate from crates.io, decode label images or RGBA frames in process and return each identifier with its symbology.

Rust
use qrcode_barcode_scanner::{ImageInput, ScanProfile, Scanner, Symbology};

let scanner = Scanner::builder().profile(ScanProfile::Frame).build();
let report = scanner.scan(ImageInput::encoded(&image_bytes))?;
let barcode = report.detections.iter().find(|d| d.symbology == Symbology::Code128);

if let Some(code) = barcode { println!("{}", code.content.text); }

Inspect the decoded identifierSTOCK-4827

Read label images

Pass PNG, JPEG, WebP or GIF bytes through ImageInput::encoded(). A Code 128 label encoding STOCK-4827 returns that exact string.

Shell
cargo add qrcode-barcode-scanner

Want to scan a barcode now? Open the online reader

Rust Barcode Scanner SDK at a glance

  • Published on crates.io & docs.rs

    crates.io

  • Native in-process core engine

    Rust 1.88+

  • EAN, UPC, Code 128, Data Matrix & more

    1D + 2D

  • Open-source license

    MIT

Embed native barcode scanning in Rust

Decode 1D retail, warehouse and 2D matrix labels in process with the Rust crate behind QR Code AI’s scanner bindings.

Read label images

Pass PNG, JPEG, WebP or GIF bytes through ImageInput::encoded(). A Code 128 label encoding STOCK-4827 returns that exact string.

Scan raw RGBA frames

Supply raw pixel buffers via ImageInput::rgba8() for camera streams or video pipelines without an image-encoding roundtrip.

Keep exact strings & formats

Read each detection’s Symbology enum and content.text string so leading zeros survive, then query your own inventory database.

Add barcode image reading in Rust

Add the crate with Cargo, filter barcode symbologies in process and return exact identifier strings.

Add the Rust crate with Cargo

Use Rust 1.88 or later and add qrcode-barcode-scanner on crates.io to your Cargo project. Full API docs are published on docs.rs.

The crate compiles the multi-format engine directly into your binary with no external CLI executable or hosted lookup calls.

Shell
cargo add qrcode-barcode-scanner

Import the module in Rust as qrcode_barcode_scanner (with underscores).

Default features compile all 16 barcode symbologies plus QR Code, Micro QR and rMQR.

Decode a barcode image in process

Build a Scanner with ScanProfile::Frame, pass encoded label bytes via ImageInput::encoded and keep the barcode symbologies your workflow needs. You can also set ScanConfig.formats so only selected readers run.

To prepare a known test label, create a Code 128 barcode with Barcode Generator containing STOCK-4827 and test the exported PNG.

Rust
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)
}

Switch from ScanProfile::Frame to ScanProfile::Full when reading low-contrast, skewed or challenging label photos.

Check report.trace.budget_exhausted == Some(false) before treating an empty detections list as final.

Inspect the decoded identifier

For a Code 128 label encoding STOCK-4827, read_barcodes returns (Symbology::Code128, "STOCK-4827"). A UPC-A value such as 012345678905 stays a String so its leading zero is preserved.

A blank image or QR-only photo returns Ok(vec![]). Unreadable files or oversized images return an Err whose err.code() identifies QRS-001 through QRS-006.

Rust barcode coverage, geometry and error handling

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 keep decoded values as strings to preserve leading zeros; linear barcodes may report endpoints rather than four corners. Use ScanConfig.formats to skip unused readers and set budget_ms to None for unbounded scans.

Limits and licensing. Oversized inputs fail with QRS-002 or QRS-003, while invalid options (such as a zero Limits cap) fail before decoding with QRS-006. Current releases are MIT-licensed (with Apache-2.0 notices in LICENSING.md); see the Rust crate README and Rust API guide.

Rust Barcode Scanner documentation and license

Official package documentation, ScanReport specification and licensing references.

Rust Barcode Scanner SDK questions

Cargo setup, barcode formats, leading zeros, RGBA frames, errors and licensing.

It is QR Code AI’s open-source MIT Rust crate (qrcode-barcode-scanner) for decoding 1D and 2D barcodes (and QR codes) directly in process. It powers the other language bindings and returns a typed ScanReport with symbology, exact strings, raw bytes and measured geometry.

With default features 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, plus QR Code, Micro QR and rMQR. ISBN, GS1-128 and ITF-14 return ean13, code128 and itf.

Rust 1.88 or later is required. Pass encoded PNG, JPEG, WebP or GIF bytes with ImageInput::encoded, or pass raw RGBA pixel buffers with ImageInput::rgba8 to avoid image-format roundtrips.

No. The engine returns each encoded identifier, its Symbology and parsed GS1 payload fields when recognized. Preserve identifiers as strings so leading zeros survive, and query your own catalog or inventory database separately.

Yes. Configure ScanConfig.formats with the symbologies you want; no reader of another symbology runs, and report.trace.formats records the active filter. Leaving formats empty scans every compiled symbology.

No barcode found returns Ok with an empty detections list (confirm trace.budget_exhausted == Some(false) for a final result). Corrupt or oversized inputs, cancellation and invalid options return an Err with QRS-001 through QRS-006 on err.code().

No. Decoding runs entirely locally inside your Rust process with zero network requests, no QR Code AI account, no API key and no creation credits.

Yes. Current releases are published under the MIT license, allowing commercial and proprietary use while keeping copyright and license notices (see LICENSING.md for third-party Apache-2.0 notices). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.