pub type BuiltinComponent = fn(&str) -> Option<(&'static [u8], u32)>;Expand description
Resolves a built-in rule name to its embedded component.
The sibling of BuiltinSource, and it lives here for one reason: lanekeep/<name> has
to mean one thing. A built-in shipped as a component is not importable, and the resolver
is what has to say so — a name it did not know about would come back “no built-in rule by
that name”, which is what a typo looks like and would send a reader hunting for a
misspelling that is not there.
Nothing in this crate loads the bytes. lanekeep-config reads them through
RuleRoot::builtin_component when a config names one, exactly as it reads a .wasm path.
Keeping both lookups on one value is what stops a name resolving to a module in one place
and a component in another.
The index is part of the answer. One artifact hosts several rules — the four TypeScript built-ins share one — so bytes alone name a program rather than a rule. A lookup returning only bytes would leave the caller to run whichever rule the component enumerates first, and a wrong rule reporting is indistinguishable from a right one reporting.