Skip to main content

ResourceModel

Struct ResourceModel 

Source
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: EmissionPrefix

The 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: Path

The path to the ingraph crate itself — ::ingraph unless #[ingraph(crate = "…")] named another.

§name: Ident

The 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: ResourceMode

WHICH 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

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for ResourceModel

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResourceModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.