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: PathWhere ingraph lives, for the shelf every emitted path is rooted at.
vis: VisibilityThe declaration’s visibility, which every emitted item takes.
name: IdentThe 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
impl EnumModel
Sourcepub fn form(&self, namespace: Namespace) -> StorageForm
pub fn form(&self, namespace: Namespace) -> StorageForm
The form one namespace takes: the declared override, else the namespace’s own default.
Sourcepub fn width(&self) -> IntegerWidth
pub fn width(&self) -> IntegerWidth
The width the discriminant is stored at: the declared #[repr(…)], else
IntegerWidth::DEFAULT.
Sourcepub fn error(&self) -> Ident
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.
Sourcepub fn escape(&self) -> Option<&EnumVariant>
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.
Sourcepub fn refuses(&self) -> bool
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.
Sourcepub fn restated(&self) -> impl Iterator<Item = &EnumVariant>
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.
Sourcepub fn promoted(&self, kind: GraphqlKind) -> impl Iterator<Item = &Delegate>
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.
Sourcepub fn emitted_methods(&self) -> Vec<Emitted>
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:
| row | Origin |
|---|---|
VARIANTS, the restated roster | Origin::Roster |
remote(), the materialization gate | Origin::Materialization |
one is_… per variant, the ESCAPE included | Origin::Predicate |
| one forwarding method per MINTED delegate | Origin::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.
Sourcepub fn emit(&self) -> TokenStream
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 escape | an #[ingraph(other)] escape | |
|---|---|---|
no remote | a CLOSED vocabulary this crate declares — below | an 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.