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
75
76
77
78
79
80
81
82
83
84
85
86
87
//! LANES — the partitions one corpus is cut into, the gate a tag reaches one through, and the roster
//! a slot publishes.
//!
//! ```text
//! "zh-Hant-TW" ─▶ reduce ─▶ "zh-Hant" ─▶ accepted by lane `zh` ─▶ LaneIdent("zh")
//! "en-US" ─▶ reduce ─▶ "en" ─▶ keyed lane `en` ─▶ LaneIdent("en")
//! "sw" ─▶ reduce ─▶ "sw" ─▶ nothing ─▶ a refusal that NAMES the roster
//! ```
//!
//! A full-text index is one field with one tokenizer and its schema cannot change, so a corpus whose
//! text is written in several languages is answered by SEVERAL INDEXES rather than by one clever
//! one. A **lane** is one of those partitions: a key, the tags it accepts, and — one layer down, in
//! the backend's own block — the analyzer built for it.
//!
//! # WHAT LIVES HERE, AND WHY IT IS SO LITTLE
//!
//! The lane's existence is an engineering answer to ONE ENGINE'S PHYSICS — a field has a tokenizer,
//! a schema is immutable — rather than a concept the domain has. So the ruling that created it put
//! the vocabulary where the limitation is, INSIDE the backend's own block, and gave the neutral
//! layer exactly one new thing: **a slot publishes a roster of opaque [`LaneIdent`]s**, and every
//! reader that needs to know a corpus's partitions asks that seam.
//!
//! Nothing here parses a backend block, and nothing here knows what a tokenizer is. A lane key and
//! an analyzer's name are words a declaration wrote for a backend to read, and this module carries
//! the first as an opaque identifier and never sees the second.
//!
//! # THE GATE IS THE ONE SOURCE OF NORMALISATION, and it cannot be gone round
//!
//! A tag arrives from a dozen places in a dozen spellings — `en-US` from a browser, `zh_Hant` from a
//! POSIX locale, `cmn` from a corpus tool, `zh-Hant-TW` from a language identifier — and every one
//! of them has to reach the same lane or the index side and the query side would disagree about
//! where a document lives. [`lane_for`] is where that happens, once:
//!
//! **BROAD IN.** The tag is first reduced by [`LanguageTag`] — RFC 5646's SYNTAX and nothing else,
//! no IANA registry — to a primary subtag and an optional script, with region, variant, extension
//! and private-use dropped. `en-US`, `en-GB` and `en-Latn-US-posix` all become `en`.
//!
//! **SIX STEPS, IN THIS ORDER**, and the order is the whole design:
//!
//! | | step | example |
//! |---|---|---|
//! | ① | an exact KEY | `zh` reaches the lane keyed `zh` |
//! | ② | an exact ALIAS | `zh-Hant` reaches a lane that declared `zh_hant` |
//! | ③ | a language-only KEY | `zh-Hant` reaches the lane keyed `zh` when nobody declared the script |
//! | ④ | a language-only ALIAS | `sr-Latn` reaches a lane that accepts `sr` |
//! | ⑤ | the declared CATCH-ALL | `sw` reaches the lane that wrote `catch_all()` down |
//! | ⑥ | otherwise, a REFUSAL | naming the tag, the roster, the aliases, and that no catch-all exists |
//!
//! **DECLARED ALWAYS OUTRANKS DERIVED.** That is the law the first four steps are an expression of,
//! and the one a reader could otherwise get backwards: an exact alias beats a language-only key. A
//! lane declaring `zh-Hant` literally has said something about THAT TAG; a lane keyed `zh` has said
//! something about the language, from which `zh-Hant` is only derived. So the declaration wins, even
//! when the keyed lane comes first in the roster.
//!
//! Steps ③ and ④ are what make a wide roster runnable: a corpus with thirty-two scripts' worth of
//! text does not have to hand-write an alias per script, because a tag whose language is declared
//! finds its near-home by itself.
//!
//! **STRICT OUT.** What comes back is the lane's own key and never the caller's spelling, so two
//! tags that mean one lane produce one identifier.
//!
//! # THE FALLBACK IS DECLARED, NEVER ASSUMED
//!
//! The doctrine is *no UNDECLARED fallback* — not *no fallback*. Falling back to a lane nobody chose
//! would be the silent mis-filing this gate exists to prevent, and a document quietly filed under
//! the wrong analyzer is a bug that surfaces as bad search results months later. Falling back to a
//! lane somebody WROTE DOWN is a decision: it is a visible roster row, it appears in every listing
//! and every refusal, and a reader can see exactly where the strangers go. A roster may declare
//! exactly one, and [`lane_collisions`] refuses the second.
//!
//! # WHAT IS NOT HERE
//!
//! The DECLARATION's own grammar for the fan, the analyzer a lane is bound to at assembly, and the
//! router that turns a [`ScriptRun`](crate::ScriptRun) into a tag are all downstream of this and are
//! not this module's. The division is the ruling's own: the lane's EXISTENCE is a declaration fact
//! that shapes a slot, its INSTANCE is an assembly fact that arrives at boot, and routing is policy.
pub use LaneIdent;
pub use ;
pub use LanguageTag;