1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Grid Matrix (AIMD014 / GB/T 27766) encoder and structural decoder.
//!
//! Grid Matrix is a Chinese national 2D matrix symbology. A symbol is a square array
//! of `2·v + 1` **macromodules** per side (version `v` = 1…13); each macromodule is a
//! 6×6 block whose fixed perimeter forms the alternating "grid" and whose 4×4 interior
//! carries a 2-bit layer-id plus two 7-bit codewords. Error correction is Reed–Solomon
//! over GF(2^7).
//!
//! Layout:
//! - [`gf`] — GF(2^7) arithmetic (primitive `0x89`) and Reed–Solomon.
//! - `tables` — versions, EC levels, and the per-version RS block structure.
//! - `data` — mode-switched data encodation and canonical segmentation.
//! - `layout` — macromodule placement, the frame, and the layer-id metadata.
//! - `encode` — [`Symbol`] → [`BitMatrix`].
//! - `decode` — [`BitMatrix`] → [`Symbol`].
//!
//! # Scope
//!
//! All 13 versions are implemented, along with the full five-level Reed–Solomon block
//! structure (transcribed from zint). Data encodation covers **Numeric**, **Upper**,
//! **Lower** and **Byte** modes; **Mixed** and **GB2312 Chinese** modes are modelled
//! but not produced by the encoder (the decoder reports them as unsupported). See
//! `data` for the exact per-mode bit formats and the small, documented deviations in
//! byte mode.
//!
//! # Losslessness and metadata
//!
//! [`GridMatrixEncoder::build`] splits the payload into a canonical mode segmentation
//! that the decoder reconstructs exactly, so `encode(decode(x)) == x`. [`GridMatrixMeta`]
//! records the version, EC level, and per-segment mode sequence needed to re-encode
//! identically.
//!
//! Grid Matrix defines **no** QR-style data mask: the alternating macromodule frame
//! already balances the module pattern, and the version/EC metadata rides in redundant
//! layer-id rings rather than a masked format field. `GridMatrixMeta` therefore stores
//! no mask (a deliberate deviation from the task's generic "version/EC/mask" shape).
//!
//! [`Symbol`]: crate::Symbol
//! [`BitMatrix`]: crate::output::BitMatrix
pub use GmMode;
pub use GridMatrixDecoder;
pub use GridMatrixEncoder;
pub use ;
/// Grid Matrix parameters needed to re-encode a symbol identically (lossless
/// round-trip).