#[repr(u8)]pub enum IndexKind {
Standard = 0,
Unique = 1,
Each = 2,
Composite = 3,
}Expand description
What kind of secondary index a given IndexSpec declares.
The on-disk numeric discriminants are pinned by
docs/format.md § Indexes — IndexKind. The #[repr(u8)]
attribute mirrors the spec so a future format-version that
streams the kind as a single byte (instead of postcard’s
variant-index varint) can do so without a migration.
Variants§
Standard = 0
Non-unique scalar index. One B-tree entry per document — the
encoded key carries the document’s Id as an 8-byte
big-endian suffix to keep the B-tree key globally unique
(the M4 B+tree rejects duplicate keys).
Unique = 1
Unique scalar index. Encoded key is the user value alone (no
Id suffix); collisions are surfaced as
crate::Error::UniqueConstraintViolation.
Each = 2
Multi-value index over a Vec<T> field. Emits one entry per
element of the indexed sequence. Like Standard, the
document’s Id is appended to each encoded user key.
Composite = 3
Multi-field composite index. The B-tree key is the
concatenation of every encoded field in key_paths order,
prefixed by a single envelope tag byte. Composite indexes
also append the Id suffix (composite + unique is not a
supported combination in M7 — Composite is non-unique by
construction).