# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
rxing is a Rust port of ZXing (Java barcode library), supporting encoding and decoding for 18+ barcode formats (QR, DataMatrix, Aztec, PDF417, Code128, EAN, UPC, etc.). It tracks ZXing 3.5.1. Minimum Rust version: 1.85.
## Commands
```bash
# Build
cargo build --workspace --release
# Test all (with default features)
cargo test --workspace --release --verbose
# Test with no default features
cargo test --workspace --release --verbose --no-default-features
# Run a single test
cargo test --lib <test_name>
cargo test --test <integration_test_name>
# Lint
cargo clippy --workspace --all-targets --all-features
# Format
cargo fmt --all
# Benchmarks
cargo bench --release
```
## Architecture
### Workspace Members
- Root crate (`rxing`) — main barcode library
- `crates/one-d-proc-derive` — proc macros for 1D barcodes
- `crates/cli` — CLI tool
### Core Decode Path
1. **LuminanceSource** — abstracts image input (`BufferedImageLuminanceSource`, `Luma8LuminanceSource`, `RGBLuminanceSource`, `PlanarYUVLuminanceSource`, `SVGLuminanceSource`)
2. **Binarizer** — converts to binary (`HybridBinarizer` is default/recommended; `GlobalHistogramBinarizer` is the alternative)
3. **BinaryBitmap** — wraps binarizer for use by readers
4. **MultiFormatReader** (`src/multi_format_reader.rs`) — main decoder entry point; dispatches to format-specific readers
5. **RXingResult** — output containing decoded text, raw bytes, format, and metadata
### Key Entry Points
- `src/helpers.rs` — high-level convenience functions (`detect_in_file`, `detect_in_luma`, `detect_in_image`, `detect_multiple_in_*`, `save_image`, etc.)
- `src/multi_format_reader.rs` — core multi-format decoder
- `src/multi_format_writer.rs` — core multi-format encoder
- `src/filtered_image_reader.rs` — pyramid-based image scanning for difficult images
### Module Layout
- `src/common/` — shared utilities: `BitArray`, `BitMatrix`, `BitSource`, `HybridBinarizer`, Reed-Solomon, grid sampler, perspective transform, ECI/charset handling
- `src/qrcode/` — QR: has both a pure-Rust reader (`qr_code_reader.rs`) and a faster C++ port (`cpp_port/`); cpp port is tried first
- `src/oned/` — all 1D barcode formats; `cpp/` subdirectory contains C++ ported readers; `rss/` for RSS-14/Expanded
- `src/aztec/`, `src/datamatrix/`, `src/maxicode/`, `src/pdf417/` — 2D format modules
- `src/multi/` — multiple barcode detection in a single image
- `src/client/` — result data parsing (behind `client_support` feature)
### Traits
- `Reader` / `ImmutableReader` — barcode decoding
- `Writer` — barcode encoding
- `Binarizer` — image binarization
- `LuminanceSource` — image data abstraction
### Configuration
- `DecodeHints` (`src/decode_hints.rs`) — `PossibleFormats`, `TryHarder`, `AlsoInverted`, `Assume2D`, etc.
- `EncodeHints` (`src/encode_hints.rs`) — `Width`, `Height`, `Margin`, `QR_VERSION`, `ERROR_CORRECTION`, etc.
### Feature Flags
- `image`, `image_formats` — image crate integration (default on)
- `client_support` — result parsing (default on)
- `serde` — serialization (default on)
- `svg_write` / `svg_read` — SVG support
- `wasm_support` — WASM compatibility
- `experimental_features` — risky/unstable features
- `otsu_level` — Otsu binarizer (not well tested)
### Testing
- Integration tests: `tests/` (blackbox tests per format, GitHub regression tests)
- Test images: `test_resources/`
- Unit tests: inline `#[cfg(test)]` modules throughout source