Rust Barcode Scanner SDK

Embed offline 1D and 2D barcode scanning directly inside your Rust binary or backend service. Add the MIT-licensed core crate from crates.io, decode label images or RGBA frames in process and return every identifier alongside 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

Need to scan a barcode right away? Open 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 licence

    MIT

Embed native barcode scanning in Rust

Decode retail, warehouse and 2D matrix labels in process using the core Rust crate powering 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

Feed 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 stay intact, 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 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 decoder directly into your binary with no external CLI binary or hosted lookup requests.

Shell
cargo add qrcode-barcode-scanner

Import the module in Rust source as qrcode_barcode_scanner (using underscores).

Default Cargo features enable all 16 barcode symbologies alongside 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 expects. You can also populate ScanConfig.formats so only those readers run.

To prepare a test fixture, generate a Code 128 barcode with Code 128 Barcode Generator encoding 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 decoding low-contrast, skewed or worn 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 code such as 012345678905 stays a String with its leading zero intact.

A blank image or QR-only photo returns Ok(vec![]). Unreadable bytes or oversized inputs return an Err whose err.code() identifies QRS-001 to 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 and ITF-14 to itf).

Strings, geometry and budgets. Always keep decoded values as strings so leading zeros survive; 1D barcodes may return endpoints instead of four corners. Set 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 pre-decode 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.

Rust Barcode Scanner documentation and licence

Official crate guides, 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-licensed Rust crate (qrcode-barcode-scanner) for decoding 1D and 2D barcodes (plus QR codes) straight in process. It powers every other language binding and returns a typed ScanReport carrying symbology, exact strings, raw bytes and measured geometry.

With default features it decodes 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 map to ean13, code128 and itf.

Rust 1.88 or later is required. Supply encoded PNG, JPEG, WebP or GIF bytes through ImageInput::encoded, or pass raw RGBA pixel buffers via ImageInput::rgba8 to skip image-format roundtrips.

No. The engine returns each encoded identifier, its Symbology and parsed GS1 fields when recognised. Store identifiers as strings so leading zeros stay intact, and query your own catalogue or inventory database separately.

Yes. Set ScanConfig.formats to the symbologies you want; readers outside that list never execute, and report.trace.formats records the active filter. Leaving formats empty scans every compiled symbology.

When no barcode is found, 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().

No. 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, permitting commercial and proprietary use while keeping copyright and licence notices intact (see LICENSING.md for third-party Apache-2.0 notices). SDK usage is separate from QR Code AI’s paid creation plans and seven-day Premium trial.