Skip to main content

Crate anyd

Crate anyd 

Source
Expand description

§AnyDCode

A from-scratch Rust library for decoding and encoding 1D and 2D barcodes, aiming for the widest possible symbology coverage while preserving every variation of a code.

§Design goals

  • Lossless round-trip. A decoded Symbol carries not just its payload but the exact encoding decisions (segmentation, version/size, error-correction level, mask, …). Feeding a decoded symbol straight back into the encoder reproduces the original symbol byte-for-byte. See codes::qr.
  • Live-video ready. The pipeline splits a cheap per-frame detection pass from a heavier analysis/decode pass, and carries pipeline::Hints forward so codes already decoded in earlier frames are not re-analyzed.
  • Portable input. The video boundary is a borrowed luminance buffer (GrayFrame); callers own capture and color conversion.

§Status

The full Symbology catalog is modeled, but only Symbology::QrCode is implemented so far. Query Symbology::is_implemented at runtime.

§Example: QR round-trip

use anyd::codes::qr::{EcLevel, QrDecoder, QrEncoder};
use anyd::traits::{Decode, Encode};

let encoder = QrEncoder::new();
let symbol = encoder.build_text("HELLO WORLD", EcLevel::Q).unwrap();
let encoding = encoder.encode(&symbol).unwrap();

let decoded = QrDecoder::new().decode(&encoding).unwrap();
assert_eq!(decoded.text().as_deref(), Some("HELLO WORLD"));
// Re-encoding the decoded symbol yields the identical matrix.
assert_eq!(encoder.encode(&decoded).unwrap(), encoding);

Re-exports§

pub use error::Error;
pub use error::Result;
pub use image::GrayFrame;
pub use image::GrayImage;
pub use segment::Mode;
pub use segment::Segment;
pub use symbol::Symbol;
pub use symbol::SymbolMeta;
pub use symbology::Dimension;
pub use symbology::Symbology;

Modules§

codes
Per-symbology implementations. Each submodule provides encode/decode (and later detection) for one symbology family. Only qr is implemented so far; the other modules are pre-declared stubs whose encode/decode return crate::Error::Unsupported until filled in. Query crate::Symbology::is_implemented for current coverage.
detect
Fast, symbology-agnostic frame-level code locator.
error
Error and result types shared across the crate.
geometry
Geometric primitives used to describe where a symbol sits inside a frame.
image
Frame buffer types for the live-video decoding path.
imgproc
Symbology-agnostic image-processing toolkit shared by 2D barcode samplers.
output
Abstract encoder output: the geometry of a symbol independent of pixels.
pipeline
The live-video decoding pipeline: a fast per-frame detection pass that only locates and classifies candidate codes, separated from a heavier analysis pass that fully decodes them.
render
Rasterize an abstract Encoding into an owned grayscale GrayImage.
scan1d
Generic 1D (linear) image front-end.
segment
Data segments: the mode-tagged pieces a symbol’s payload is split into.
symbol
Symbol — the decoded representation of a barcode, and the exact input the encoder consumes to reproduce it.
symbology
The catalog of barcode symbologies AnyDCode intends to support.
traits
The core traits every symbology plugs into: Detect, Analyze, Decode and Encode. They mirror the two-stage live pipeline (locate cheaply, then decode) while also supporting one-shot still-image decoding.
transform
Deterministic, dependency-free image transforms on owned GrayImages.