Expand description
Subject-pattern matching (RFC 08 §1/§2, issue #7).
One implementation of the registry’s {var} / {var...} pattern
semantics, shared by the codegen (zenkey-build orders generated parse
arms by SubjectPattern::precedence) and by runtime tools (zenctl’s
subject refinement delegates here). Before v1.5 the two carried separate
hand-rolled copies of the same rules with no parity guarantee.
Semantics (byte-compatible with the generated parse):
- a literal chunk matches itself, exactly;
{var}matches exactly one chunk and binds it;{var...}is trailing-only and matches one or more chunks (an empty rest is not a match — the family key without a tail is a different, unregistered key);- precedence at the first differing position: literal < var < rest; ties break by pattern text (stable).
The zenoh KeFormat engine can express the literal/{var} subset
(SubjectPattern::ke_format_spec); it cannot express our rest
semantics (** matches zero chunks; {var...} requires ≥ 1) nor the
verbatim-chunk rules, so the hand matcher here is normative and the
KeFormat bridge is an interop convenience, parity-pinned in tests.
Structs§
- Subject
Pattern - A parsed registry subject pattern.
Enums§
- Pattern
Chunk - One position of a subject pattern.
- Pattern
Error - A pattern parse failure.
Functions§
- best_
match - The most-literal-first winner across a pattern set: the pattern that the generated parse (which emits arms in precedence order) would select. Returns the winning pattern’s index and its bindings.