Skip to main content

Module resource

Module resource 

Source
Expand description

The RESOURCE declaration’s emission: citizenship, the mode the declaration recorded, and — where a BUILTIN KIND WORD was written — the engine the macro mints and the impls that delegate to it.

ⓘ
#[ingraph::resource]          pub struct Egemma { model: EgemmaModel } // FOREIGN: hand impls
#[ingraph::resource(async)]   pub struct MyRemote(RemoteQdrant);       // FOREIGN, awaited faces
#[ingraph::resource(tantivy)] pub struct Ft;                           // BUILTIN: the macro mints

§THE FOREIGN FORM emits ONE ITEM, and the item is two refusals

impl DeclaredResource for Egemma { … } — the CITIZENSHIP, which the walk enumerates. The trait’s SUPERTRAIT is what makes the same line an assert: DeclaredResource: AsyncResource, so a declaration with no AsyncResource impl is E0277 AT THE DECLARATION; and AsyncResource: Send + Sync, so a type that cannot cross threads is refused at the same site, which is the earliest one there is.

Its BODY is the mode the declaration recorded — const SYNC — and that is the whole of what the async word buys here. The faces themselves stay the author’s own hand: this is the OPEN SEAM, and a macro that wrote an engine impl for a type it has never seen would be closing it.

§A SECOND audit was written and removed, and the measurement is why

Every other emission in this crate states a bound it wants a reader to meet as a sentence through an audit CALL in an anonymous const — stores_rows’s shape. One was written here, and the measurement is that rustc reports the missing contract at the DECLARATION’s own type name either way, with the on_unimplemented note either way — so the audit produced a second error saying exactly what the first one said. It is gone, and the note is what stops it being rediscovered.

§THE BUILTIN FORM is the same declaration with the engine filled in

A kind word names one of the framework’s own engines, so everything the foreign author writes by hand is known here and is written for them: the declaration is re-emitted CARRYING the engine (a kind word takes a declaration with no fields, precisely so the macro owns the one it mints), the AsyncResource impl opens it, and the base plus the two faces of the engine’s OWN MODE delegate to it. No face of the other mode is emitted, because the kind word carries the mode knowledge and a second face would be this crate claiming a posture the engine does not have.

It rides the engine’s own cargo gate, and the shut half carries the author’s declaration back beside a compile_error! — see ResourceKind::gate.

§No accessor family, and that is the tier rather than an omission

A record’s expansion hands its fields out; a resource’s does not. A resource is reached through Shared<R>, which derefs to the type itself, so what a member can do with one is whatever the AUTHOR’s own inherent impl offers. Emitting accessors would put this crate’s naming convention on a type whose whole surface is somebody else’s.

The BUILTIN form has two inherent items anyway, and the line is exactly the one above: the macro MINTED that engine, so the two doors onto it are this crate’s to name — see ResourceKind::emit.

Structs§

ResourceModel
A validated resource declaration, ready to emit.

Enums§

ResourceKind
A BUILTIN ENGINE a resource declaration may name in one word — the CLOSED framework vocabulary.
ResourceMode
WHICH FACE a resource’s engine impls wear — the async word, as a closed vocabulary.