Skip to content

Implement the new native qr encoder - #10

Merged
magiclen merged 16 commits into
masterfrom
native-qr-encoder
Jul 18, 2026
Merged

magiclen merged 16 commits into
masterfrom
native-qr-encoder

Conversation

@magiclen

Copy link
Copy Markdown
Owner

No description provided.

magiclen added 16 commits July 13, 2026 08:54
Drop the qrcodegen dependency and encode every symbol family from scratch in
pure Rust (edition 2024, MSRV 1.89).

- Add the encoding pipeline: an MSB-first bit buffer, the mode and segment
  model, a dynamic-programming segment optimizer, a runtime GF(256)
  Reed-Solomon generator and remainder, block interleaving, matrix placement,
  and mask selection (lowest penalty for Model 2, highest dark-edge score for
  Micro QR, the fixed mask for rMQR).
- Support Model 2 versions 1-40, Micro QR versions M1-M4 and all 32 rMQR
  (ISO/IEC 23941) rectangular versions, with the Numeric, Alphanumeric, Byte
  and Kanji modes, plus ECI, FNC1 and Structured Append, and an AutoEncoder
  that picks the smallest family.
- Replace the free-function facade with an Encoder -> Symbol -> Renderer
  builder API exposed through the qr, micro and rmqr modules, and render a
  Symbol to grayscale, SVG and PNG.
- Add the EncodeError and RenderError types, the examples and the docs.
- Make the crate no_std + alloc by default; gate std-only rendering, atomic
  file saving and async writers behind the std feature.
- Add the url feature that implements ToQRText for url::Url with case and
  percent-escape normalization.
- Tidy the example set and rename their output files, and refine the encoder
  and renderer public surface.
- Adjust the feature layout and CI accordingly.
- Move correctness testing into a single integration binary that round-trips
  every family through the quircs and rxing decoders.
- Verify the ISO capacity boundaries for every version and error correction
  level, and reproduce the Annex reference matrices module for module.
- Drop the old golden PNG/SVG fixtures.
- Rewrite the byte-mode segmentation in both the byte and text optimizers from
  O(n^2) to O(n) with a monotonic queue keyed by candidate cost, preserving the
  exact segmentation (about 8.8x faster on large text, 2.4x on large binary).
- Build the rMQR Reed-Solomon generator once per symbol instead of once per
  block, and precompute the rMQR version order by area at compile time.
- Return a clearer error when a Micro QR byte input is not representable, and
  document that Symbol::size reports the width for the rectangular family.
- Add a bencher-based benchmark suite for encoding and rendering.
@magiclen
magiclen force-pushed the native-qr-encoder branch from 20aff7d to adcc9cd Compare July 18, 2026 16:13
@magiclen
magiclen merged commit aca2d8b into master Jul 18, 2026
124 checks passed
@magiclen
magiclen deleted the native-qr-encoder branch July 18, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant