Skip to main content

EnumModel

Struct EnumModel 

Source
pub struct EnumModel {
    pub krate: Path,
    pub vis: Visibility,
    pub name: Ident,
    pub width: Option<IntegerWidth>,
    pub variants: Vec<EnumVariant>,
    pub forms: BTreeMap<Namespace, StorageForm>,
    pub wire_name: Option<String>,
    pub error: Option<Ident>,
    pub remote: Option<Remote>,
}
Expand description

One vocabulary’s declaration, validated.

Public fields for the reason RecordModel’s are: nothing here parses, so a front end that is not the derive builds the same struct and reaches the same emitter.

Fields§

§krate: Path

Where ingraph lives, for the shelf every emitted path is rooted at.

§vis: Visibility

The declaration’s visibility, which every emitted item takes.

§name: Ident

The declared enum’s own name.

§width: Option<IntegerWidth>

The integer #[repr(…)] the declaration carries, when it carries one.

§variants: Vec<EnumVariant>

Its variants, in declaration order. Never empty — an enum with none has no value.

§forms: BTreeMap<Namespace, StorageForm>

The per-namespace form OVERRIDES. A namespace with no entry takes Namespace::default_form.

§wire_name: Option<String>

graphql(rename = "…") — what a SCHEMA calls this vocabulary, where the declaration moved it.

None is the Rust name unraw’d, which is what EnumModel::sdl_name resolves.

EMISSION-ONLY, and that is the whole of its reach: nothing in Rust and nothing in a database reads this word, so a declaration writing one keeps every minted type name, every accessor and every stored word it had. It is a String rather than a syn::Ident because nothing in Rust is called this — see EnumModel::sdl_name for the grammar it is held to instead.

§error: Option<Ident>

What the emitted REFUSAL type is called, when the declaration named it.

None is <Enum>ParseError, which is what EnumModel::error resolves. The knob exists for a COLLISION rather than for taste — see the module note — so the default is not a thing anyone has to reach for, and a declaration that names nothing is unaffected by the knob’s existence.

§remote: Option<Remote>

The UPSTREAM vocabulary this declaration mirrors, when it mirrors one.

None is the whole of today’s mode and nothing about it moves: a vocabulary that names no upstream owns its own words, stores a discriminant and publishes a GraphQL enum. See remote for what the other mode is and why it is a different emission rather than a flag through this one.

Implementations§

Source§

impl EnumModel

Source

pub fn form(&self, namespace: Namespace) -> StorageForm

The form one namespace takes: the declared override, else the namespace’s own default.

Source

pub fn width(&self) -> IntegerWidth

The width the discriminant is stored at: the declared #[repr(…)], else IntegerWidth::DEFAULT.

Source

pub fn error(&self) -> Ident

The refusal type this declaration’s parses answer with — the declared name, else GradeParseError.

The ONE authority on what that type is called: the emission writes this, and a front end’s collision check asks it rather than rebuilding the suffix convention on its own side.

Source

pub fn escape(&self) -> Option<&EnumVariant>

The ESCAPE variant, on a vocabulary that has one.

Its presence is what says the vocabulary is OPEN — the second axis of emit’s four cells — and every fork in [remote]’s and [own]’s emissions reads it here rather than re-deriving the question from the variant list.

Source

pub fn posture(&self) -> Option<&Escape>

The escape’s POSTURE — which of Escape’s three the declaration wrote.

Asked here rather than unwrapped at each of the six sites that fork on it, for the reason escape is: one question, one place it is answered.

Source

pub fn refuses(&self) -> bool

Whether this vocabulary’s own parse can REFUSE a word.

True of anything CLOSED — a vocabulary this crate declares, whose variants ARE the set, and a closed mirror, which reports its upstream’s refusal as its own — and of a HALF-OPEN mirror, whose gate can refuse. False of the two postures that promise every word parses, which is every OPEN vocabulary this crate declares and the two total mirror postures. It is what decides whether a refusal type is declared beside the enum at all, and therefore whether error(rename = "…") has anything to move.

Source

pub fn restated(&self) -> impl Iterator<Item = &EnumVariant>

Every variant that NAMES a member — the whole list, minus the escape.

On a mirror those are the upstream names it restates; on a vocabulary this crate declares they are the roster’s own. What they share is being the list a &'static [Self] can hold, the escape carrying a runtime word and therefore being no constant.

Source

pub fn promoted(&self, kind: GraphqlKind) -> impl Iterator<Item = &Delegate>

The delegated methods PUBLISHED at one backend, in declaration order.

The whole of the promotion law’s antecedent: a mirror with none of these renders as a scalar in both positions — today’s shape, unmoved — and a mirror with one or more renders its OUTPUT seat as an OBJECT and its input seat as a scalar called <Enum>Input. Asked HERE rather than re-derived at each of the four sites that fork on it, so a mirror cannot be promoted in one and not another.

Empty for a DECLARED vocabulary, which delegates nothing: the accessor answers about the model rather than about the mode, so a caller needs no second question first.

Source

pub fn emitted_methods(&self) -> Vec<Emitted>

Every name a MIRROR’s expansion puts in the enum’s own value namespace, in emission order.

§What it is FOR, and why it stops at the mirror

A delegate(fn …) entry restates a method name the author chose, and a mirror’s expansion declares names of its own beside it — so the two can meet, and rustc reports the meeting as E0592 at the derive, a span the author cannot edit and a message that never names the entry. This is the list a front end moves that report with, and the seat that makes it necessary is the MIRROR’s alone: a declared vocabulary has no delegate(…), so nothing an author wrote is in its namespace to collide with, and enumerating its names would be a model nothing spends.

Empty for a declared vocabulary, therefore, and empty in the promoted sense: the accessor answers about the model rather than about the mode, so a caller needs no second question first.

§The list, and where each row comes from

mirror_face is the one inherent impl a mirror emits, and it declares four kinds of name in this order:

rowOrigin
VARIANTS, the restated rosterOrigin::Roster
remote(), the materialization gateOrigin::Materialization
one is_… per variant, the ESCAPE includedOrigin::Predicate
one forwarding method per MINTED delegateOrigin::Delegate

VARIANTS is an associated CONST and is here all the same: Rust’s value namespace holds consts and functions together, so a delegate spelled VARIANTS is a duplicate definition exactly as a second remote would be.

§A WAIVED entry is enumerated, and it is the one row the emission does not write

on = self waives the forwarding mint, so nothing is emitted for that entry — but the word says the method exists on this type, written by the author’s own hand, and that method occupies the namespace exactly as a mint would. The question this list answers is which names are TAKEN, not which tokens this emitter wrote, so a waived entry is a row. It is the one asymmetry, and the pin against the emission is stated over declarations that carry no waiver for that reason.

Source

pub fn emit(&self) -> TokenStream

The whole expansion: the refusal type, then the rows, the face and the wire.

The impls sit in anonymous const _: () = { … }; blocks, as a record’s do — it changes nothing about reaching them and it gives the per-backend mapping functions a scope where they can collide with nothing the declaring module wrote. The refusal type cannot: it is named in signatures a caller writes.

The WIRE face is a second block rather than a member of this one, because the whole of it sits behind the binding gate: a build without async-graphql expands the block’s contents to nothing, and keeping it separate is what lets that be true of a gate wrapping the block’s whole body rather than of a cfg sprinkled through this one.

§FOUR CELLS, and the declaration’s own SHAPE picks one

There is no word for the mode. Two structural facts decide it — whether remote = "…" names an upstream, and whether a variant wears #[ingraph(other)] — and the four combinations are the whole grammar:

no escapean #[ingraph(other)] escape
no remotea CLOSED vocabulary this crate declares — belowan OPEN one, [own]
remote = "…"a closed MIRROR, [remote]an open mirror, [remote]

The forks are not four emissions. A mirror’s words are its upstream’s, so its face, parses, stored form and wire all differ and [remote] writes them; an open vocabulary this crate declares owns its words like the closed one below and stores them like a mirror, so [own] writes the half that is neither and shares the rest with both.

Trait Implementations§

Source§

impl Clone for EnumModel

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 EnumModel

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.