pub enum ResourceKind {
Tantivy,
}Expand description
A BUILTIN ENGINE a resource declaration may name in one word — the CLOSED framework vocabulary.
§Closed, and short, and both on purpose
A kind word is a promise that this crate can write the whole engine binding, which it can only
keep for an engine it SHIPS. So the vocabulary holds exactly the engines in the tree, and it
holds them by NAME rather than by family: tantivy is a word because
store::tantivy is an engine; lance is not, because nothing in this tree implements one, and a
word whose emission has no target is a promise made to a reader who then cannot cash it. The
OPEN half of the axis is the bare form, which needs no vocabulary at all.
§It is the ONE home of the word list
The grammar refuses an unknown kind word by naming the known ones, and the emitter writes what
each one means. Both read WORDS and from_word here, so a
word cannot be spellable in one and unknown in the other.
Variants§
Tantivy
tantivy — the shipped full-text engine: a TantivyStore connection-manager, its per-slot
TantivyFulltext handle, and a corpus per resource.
Implementations§
Source§impl ResourceKind
impl ResourceKind
Sourcepub const WORDS: &'static [&'static str]
pub const WORDS: &'static [&'static str]
Every builtin kind word, in the order a refusal lists them.
Sourcepub fn from_word(word: &str) -> Option<Self>
pub fn from_word(word: &str) -> Option<Self>
The kind word names — None for a word this vocabulary does not hold.
Sourcepub const fn mode(self) -> ResourceMode
pub const fn mode(self) -> ResourceMode
THE MODE THE KIND CARRIES, which is why a kind word takes no async beside it.
Tantivy is a SYNCHRONOUS engine — the shipped face does its work inline and the async twin is
the blocking body with ready around it — so a resource of this kind wears the blocking faces,
and nothing an author writes can make that untrue. This is what the word carries its own mode
means, and what makes resource(tantivy, async) a refusal rather than a preference.
Sourcepub fn kinds(self) -> TokenStream
pub fn kinds(self) -> TokenStream
WHAT A RESOURCE OF THIS KIND HOLDS — the facet the SOLE-DEFAULT binding is resolved against.
The word carries it for the reason it carries the mode: tantivy IS a full-text store, and an
author who wrote the word has already said so. A FOREIGN resource states it by hand — one
line, the open seam’s usual price — and says nothing by default, which costs exactly the
sole-default convenience.
Sourcepub fn blueprint(self, krate: &Path) -> TokenStream
pub fn blueprint(self, krate: &Path) -> TokenStream
WHAT A HOME LOOKS LIKE in a resource of this kind — the Habitat blueprint the word carries.
The word knows the kind and the kind knows the vocabulary: tantivy holds documents, so a
declaration’s home in one is the CORPORA it owns there. A foreign resource states it by hand,
which is one line and the open seam’s usual price.
Sourcepub fn maker(self, krate: &Path, name: &Ident) -> TokenStream
pub fn maker(self, krate: &Path, name: &Ident) -> TokenStream
THE FACTORY VISITOR a resource of this kind makes its homes with — LAYER TWO’s machine, and the face its own MODE names.
A builtin’s machine is the framework’s, because the framework wrote the engine: the word that
mints the store mints the maker for it too. The pair is (the author face to implement, the visitor type), and which face is mode’s answer — a blocking engine’s maker is
a TypeVisitor and an awaited one’s is its twin, with no bridge between them.
Sourcepub const fn gate(self) -> (&'static str, &'static str)
pub const fn gate(self) -> (&'static str, &'static str)
The two halves of the cargo gate this kind’s emission rides — the OPEN one and its complement.
The emission names types a build without the feature does not have, so it cannot be written
unconditionally, and a #[cfg(feature = …)] inside an expansion asks the DECLARING crate for a
feature it has never heard of. The gate pair is the crate’s own answer to exactly that, and this
is which pair a kind spends.
Sourcepub fn absent(self) -> String
pub fn absent(self) -> String
What a build WITHOUT this engine is told, at the declaration that asked for it.
It names the feature and the manifest, because that is the whole fix. The alternative — letting
the shut gate swallow the emission — leaves a reader an AsyncResource they never wrote and were
never going to write.
Sourcepub fn engine_field(self, krate: &Path, prefix: &EmissionPrefix) -> Field
pub fn engine_field(self, krate: &Path, prefix: &EmissionPrefix) -> Field
The FIELD a kind word injects into the declaration — the engine the macro mints.
The whole reason a resource macro is an ATTRIBUTE one: a builtin resource’s author writes
pub struct Ft; and the engine underneath it is this crate’s business, so the declaration the
compiler sees is not the declaration the author wrote. It is named the way every injected field
here is — a spelling nothing outside the emission writes — and it is PRIVATE, because the two
doors onto it are emitted beside it and are what a caller reaches.
Sourcepub fn emit(
self,
krate: &Path,
name: &Ident,
prefix: &EmissionPrefix,
) -> TokenStream
pub fn emit( self, krate: &Path, name: &Ident, prefix: &EmissionPrefix, ) -> TokenStream
Everything this kind emits for the declaration name, under the crate krate.
Three impls and one inherent block, and every one of them delegates:
| item | what it says |
|---|---|
impl AsyncResource | the store’s own construction — Options and Error are the store’s, and build is its open |
impl DeclaredResource | the citizenship, carrying the mode the KIND knows |
impl FulltextEngine | THE BASE: eight seats and the three address-lifecycle functions, projected off the store’s per-slot handle |
impl FulltextStore | THE PER-SLOT FACTORY — the mode’s own face, and the door every corpus is opened through |
impl FulltextMount | THE MODE-BLIND FACE over that factory, plus the manager it lends — what a WIRE DOOR names |
impl Habitat | WHAT A HOME LOOKS LIKE here — the corpora a declaration owns in this mount |
impl Initialize | LAYER TWO’s machine: the shipped slot maker, on the face this kind’s mode names |
impl <Type> | connection() — the one fact a caller needs to bundle a Connected |
§A RESOURCE IS A STORE, and it is NOT a corpus
This is the grain the whole emission turns on. A resource is the MOUNT — a connection-manager
opened once, holding whatever pool or index root the deployment configured — and a SLOT is one
corpus inside it, named by the ELECTION that writes it: <index>__<field>__<label>, which is
node × election and is what boot slot-shape validation checks. Two elections pointing at ONE
resource are therefore TWO corpora with two universes of BM25 statistics, which is the whole
reason the grain is where it is: docfreq over numdocs and the average document length are
INDEX-WIDE, so a title and a body sharing a corpus would move each other’s scores.
An earlier draft named ONE corpus per resource, after the declaration’s own snake name. That
read the resource as the corpus and left a deployment no way to hold two elections in one mount
without merging their statistics. The two-TypeId story — two same-kind resources being two
types and two Shared<R> lookups — is untouched and is what it always was: the answer for
genuinely TWO STORES, not the answer for two corpora.
§The BASE is projections and nothing else, which is what makes delegation honest
Every seat is written as <TantivyFulltext as FulltextEngine>::… rather than as the concrete
type it resolves to. So the day the engine changes one of them, this expansion changes with it
and no declaration has to be re-emitted against a copy that drifted. The three lifecycle
functions are ASSOCIATED ones, which is why the base needs no value at all to delegate.
The base is also SLOT-BLIND — eight type seats and three address functions, not one of which
names a corpus — which is exactly why it can sit on the mount. It is [the kind trait]: a leg
writing resource = "crate::Ft" is verified by projecting through it, so a vector election
pointed at a full-text resource is E0277 at the path its author wrote.
§NO READ AND NO WRITE FACE, and the slot grain is why
FulltextRead::search and FulltextWrite::upsert carry no slot parameter — the per-slot
HANDLE is what carries it, minted at the corpus name. A face on the mount would therefore have
to bake ONE corpus name into itself, which is the reading this emission just refused. So the
mount wears the FACTORY and the handle it mints wears the faces, and the two are never confused
because they are two types.
§The mode’s FIRST TRUE SPEND is which factory face is written
mode picks FulltextStore for a blocking store and AsyncFulltextStore for an
awaited one. The pair differs in exactly one verb — open — because the per-slot factory is
synchronous and infallible on both faces, so open is the whole of what a mode can change
here. Tantivy’s open is two syscalls and no await, so a tantivy resource is written on the
BLOCKING face; the transitional posture that bound the awaited face regardless ends at this
line.
§…and the MOUNT is where that spend stops leaking outward
Face selection happens AT THIS EMISSION and nowhere downstream, which is the whole reason
FulltextMount exists: a wire door is expanded at an ELECTION, in a crate that can see the
resource’s path and not its mode, so a door written over either store face would serve half
the resources there are. The two templates here — FulltextStore at Block,
AsyncFulltextStore at Async — both close into one mode-blind seam, and the selection is
therefore paid once by the party that knows the answer.
§The one inherent door, and why it is not the accessor family the module refuses
connection() hands out the manager THIS MACRO opened. That is a fact about the field the
macro injected, not about anything the author wrote — so naming it here is this crate naming
its own mint, which is the opposite of putting a convention on somebody else’s surface. A
caller needs it to bundle a Connected, the connection
being the borrow every verb takes back.