pub struct ResourceModel {
pub prefix: EmissionPrefix,
pub krate: Path,
pub name: Ident,
pub kind: Option<ResourceKind>,
pub mode: ResourceMode,
}Expand description
A validated resource declaration, ready to emit.
PLAIN, for the reason every model in this crate has plain fields: the derive today and a manifest front end later reach the same emitter.
Fields§
§prefix: EmissionPrefixThe EMISSION NAMESPACE this declaration’s minted names wear.
EmissionPrefix::INGRAPH for everything ingraph’s own front ends build, and a domain
framework’s own mark for a model mediagraph-codegen or its successors build — see
crate::prefix for what the seat covers and why it is a field rather than a constant.
krate: PathThe path to the ingraph crate itself — ::ingraph unless #[ingraph(crate = "…")] named
another.
name: IdentThe declared type — what the citizenship is emitted for.
kind: Option<ResourceKind>The BUILTIN ENGINE this declaration named in one word — None for the FOREIGN form, which is
the open seam and emits no engine impl at all.
mode: ResourceModeWHICH FACE this resource’s engine impls wear.
The async word where the declaration is foreign, and the KIND’s own answer where it is not —
which is why the two are refused together: a builtin’s mode is knowledge the word carries, and
a second opinion beside it could only disagree.
Implementations§
Source§impl ResourceModel
impl ResourceModel
Sourcepub fn carried_engine(&self) -> Option<Field>
pub fn carried_engine(&self) -> Option<Field>
The field a BUILTIN kind word injects into the host — None for the foreign form, whose
declaration is echoed exactly as written.
Sourcepub fn emit(&self) -> TokenStream
pub fn emit(&self) -> TokenStream
The IMPLS — the citizenship, and whatever a kind word adds beside it.
The host is not here: an attribute macro replaces the item it sits on, and assembling the two is
expand’s job because only the caller holds the declaration. This is what a
reader asserts against.
Sourcepub fn expand(&self, plain: &TokenStream, carrying: &TokenStream) -> TokenStream
pub fn expand(&self, plain: &TokenStream, carrying: &TokenStream) -> TokenStream
THE WHOLE EXPANSION — the declaration and the impls, assembled under whichever gate the declaration’s kind rides.
plain is the author’s own host, re-emitted; carrying is that host with
carried_engine appended. THE HOST IS EMITTED WHETHER OR NOT the
declaration was accepted and whichever half of a gate survives, for the reason every attribute
macro in this family states: the macro replaces the item it sits on, so an expansion that
dropped the host would delete the type and bury its own message under every mention of it.
The FOREIGN form has no gate and no injection, so it is the two token streams’ concatenation and nothing more — the semantics it has always had.