Rust QR Code Scanner SDK

Embed offline QR code scanning directly inside your Rust binary or library. Pull the MIT-licensed core crate from crates.io, supply encoded image bytes or raw RGBA pixels and inspect strongly typed detections and QR scannability scores in process.

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 qr = report.detections.iter().find(|d| d.symbology == Symbology::QrCode);

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

Inspect the decoded resulthttps://qrcode-ai.com/

Read saved QR images

Supply PNG, JPEG, WebP or GIF bytes via ImageInput::encoded() to decode links, text and structured payloads locally.

Shell
cargo add qrcode-barcode-scanner

Need to scan a QR code right away? Open the online reader

Rust QR Code Scanner SDK at a glance

  • Published on crates.io & docs.rs

    crates.io

  • Native in-process core engine

    Rust 1.88+

  • Zero network calls or child processes

    In-process

  • Open-source licence

    MIT

Embed native QR scanning in Rust

Scan encoded images or raw RGBA pixel buffers in process with the Rust crate powering every QR Code AI scanner binding.

Read saved QR images

Supply PNG, JPEG, WebP or GIF bytes via ImageInput::encoded() to decode links, text and structured payloads locally.

Scan raw RGBA frames

Feed raw pixel buffers through ImageInput::rgba8() to skip image re-encoding in camera streams or video pipelines.

Inspect typed reports

Access detections, physical occurrences, QR scannability scores and trace.budget_exhausted straight from typed Rust structs.

Add QR image scanning in Rust

Add the crate using Cargo, decode encoded PNG bytes in process and print the extracted QR text.

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 available on docs.rs.

The crate links the core decoding engine straight into your binary, with no external CLI executable or outbound network calls.

Shell
cargo add qrcode-barcode-scanner

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

Compiled symbology readers reflect your chosen crate features; query the capabilities API to inspect enabled readers.

Decode a QR image in process

Build a Scanner configured with ScanProfile::Full, feed image bytes via ImageInput::encoded and retain QR code detections (Symbology::QrCode). Inspect report.trace.budget_exhausted and content.charset whenever byte-exact payload fidelity matters.

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

fn read_qr_image(path: &str) -> Result<Vec<String>, Box<dyn std::error::Error>> {
    let bytes = std::fs::read(path)?;
    let scanner = Scanner::builder().profile(ScanProfile::Full).build();
    let report = scanner.scan(ImageInput::encoded(&bytes))?;

    let urls = report
        .detections
        .iter()
        .filter(|d| d.symbology == Symbology::QrCode)
        .map(|d| d.content.text.clone())
        .collect();
    Ok(urls)
}

Pick ScanProfile::Frame for fast decoding without a QR quality score, ScanProfile::Fast for lighter scoring or ScanProfile::Full for the deepest preprocessing ladder.

Use ImageInput::rgba8 for raw pixel buffers and set ScanConfig.formats to run only the symbologies you require.

Inspect the decoded result

For a QR image encoding https://qrcode-ai.com/, read_qr_image returns Ok(vec!["https://qrcode-ai.com/"]). Repeated physical copies of the same payload are grouped into a single detection entry with multiple occurrences.

An image with no QR code yields Ok with an empty detections vector rather than an Err. Invalid inputs (QRS-001 to QRS-004), cancellation (QRS-005) and invalid options (QRS-006) return an Err you can match via err.code().

Rust core architecture, budgets and error handling

Multi-engine core. The crate pairs rxing and rqrr inside a deterministic pipeline, accepts PNG, JPEG, WebP, GIF and raw RGBA8 inputs, and exposes ScanConfig.formats so only the readers you need run.

Budgets and payload fidelity. Pass None for budget_ms to run unbounded scans; treat a report as final only when trace.budget_exhausted equals Some(false). Treat a None score as unmeasured rather than zero, and inspect content.raw whenever content.charset is unknown.

Limits and licensing. Oversized images fail with QRS-002 or QRS-003, while invalid settings (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); refer to the Rust crate README and Rust API guide.

Rust QR Code Scanner documentation and licence

Official crate guides, ScanReport schema specification and licensing notices.

Rust QR Code Scanner SDK questions

Cargo setup, Rust version, RGBA frames, scoring, work budgets, error codes and licensing.

It is QR Code AI’s open-source MIT-licensed Rust crate (qrcode-barcode-scanner) that serves as the engine behind the entire scanner family. It decodes QR codes, Micro QR, rMQR and 16 barcode symbologies directly in process and returns a strongly typed ScanReport with content, geometry and QR scannability diagnostics.

Rust 1.88 or newer is required. Add the dependency using cargo add qrcode-barcode-scanner and import it in your code as qrcode_barcode_scanner.

Yes. Pass encoded PNG, JPEG, WebP or GIF bytes through ImageInput::encoded, or hand raw RGBA pixel buffers straight to ImageInput::rgba8 to avoid an image-encoding round trip.

The Full and Fast profiles compute a software QR scannability score alongside actionable hints grounded in measured properties. Frame skips scoring, and score is an Option where None means unmeasured, never zero. Software scores do not replace hardware print verification.

Every profile carries a default time budget; pass None for budget_ms to run without a time cap, and check report.trace.budget_exhausted == Some(false) before treating an empty result as final. Configure ScanConfig.formats to run only the symbology readers you need.

An image without any code returns Ok with an empty detections vector. Unreadable or oversized inputs (QRS-001 to QRS-004), cancellation (QRS-005) and invalid options such as a zero Limits cap (QRS-006) return an Err that you can branch on via err.code().

No. Decoding executes 100% locally inside your Rust process with zero network calls, no QR Code AI account, no API key and no creation credits. Decoded URLs are never fetched automatically.

Yes. Current releases ship under the MIT licence, permitting commercial and proprietary builds while retaining copyright and licence notices (check 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.