pub struct EnumVariant {
pub ident: Ident,
pub rename: Option<String>,
pub names: BTreeMap<Namespace, String>,
pub upstream: Option<Ident>,
pub escape: Option<Escape>,
pub carrier: Option<Type>,
}Expand description
One variant, with whatever the declaration renamed it to.
Fields§
§ident: IdentThe variant as Rust spells it, r# and all.
rename: Option<String>The GLOBAL rename, which moves the canonical word every namespace defaults from.
A MIRROR has none — see upstream, which is what its rename names
instead.
names: BTreeMap<Namespace, String>The per-namespace renames, each overriding the canonical word in that one face.
Always empty on a MIRROR: an upstream vocabulary spells itself, in one word, in every face.
upstream: Option<Ident>On a MIRROR, the upstream variant this one restates, when it is not spelled alike.
escape: Option<Escape>The POSTURE of the #[ingraph(other)] escape — the one variant carrying a WORD rather than
naming a member — and None on every other variant.
Its presence is the declaration saying the vocabulary is OPEN, in either mode. A vocabulary
this crate DECLARES takes Escape::Total and nothing else: the two gated postures point at a
totality living in somebody else’s crate, and an open vocabulary with no upstream has no such
place for one to live.
carrier: Option<Type>The TEXT CARRIER an escape holds its word in — the marked variant’s one unnamed field, as the
declaration wrote it — and None on every other variant.
The carrier is the declaration’s choice and this crate names no type for it: the door builds
one through From<&str> and reads one through AsRef<str>, so any text type
satisfying that pair holds a word. What is recorded here is the TOKEN, because one row needs
the type written rather than merely reachable through a bound — the key delegation, whose
Inner IS this type. Every other reader of an escape goes through the two traits and needs no
name at all.
None beside a Some escape is a model that marked an escape and recorded no carrier;
the key row is what it costs, and the derive never builds one — see
key_delegation.
Implementations§
Source§impl EnumVariant
impl EnumVariant
Sourcepub fn canonical(&self) -> String
pub fn canonical(&self) -> String
The CANONICAL word: the global rename, else the variant’s own name unraw’d.
The r# is Rust’s escape for a word that collides with its grammar and no part of the name, so
a variant called r#type is canonically type — which is what a schema and a hand-written row
would spell.
Sourcepub fn name(&self, namespace: Namespace) -> String
pub fn name(&self, namespace: Namespace) -> String
The word one namespace spells this variant as: its own rename, else that namespace’s default over the canonical word.
Sourcepub fn folded(&self) -> String
pub fn folded(&self) -> String
The word an OPEN vocabulary spells this variant with: its rename, else the Rust name in the
framework’s own lower-case household — LeftShoulder is left_shoulder.
§Why an open vocabulary defaults DIFFERENTLY from a closed one
A closed vocabulary’s word is its variant’s name verbatim, because the set IS the declaration
and a client reading an SDL enum sees exactly the members it publishes. An open one publishes
a SCALAR, so its words meet the outside world as text — from a producer’s protobuf, a label
file, a Swift enum — and the house register’s answer for text is lower case. Defaulting to the
Rust spelling would put a Pascal word in a position every other producer writes in snake.
The default is what the five vocabularies this mode was measured against already spell by
hand: all forty-three of their words are to_snake_case of the variant name, exactly. rename
is the escape from the arithmetic, not a knob a declaration is expected to reach for.
Sourcepub fn predicate(&self) -> Ident
pub fn predicate(&self) -> Ident
The predicate this variant gets — is_low, is_h264.
Over the RUST spelling rather than the canonical word, because the method is Rust and its
reader is looking at the variant: a #[ingraph(rename = "lo")] moves what a database stores
and not what the enum is called.
Sourcepub fn upstream(&self) -> Ident
pub fn upstream(&self) -> Ident
The UPSTREAM variant a mirror’s variant restates — the declared rename, else its own name.
The mirror’s two From arms are written from this, so a name that answers to nothing upstream
is E0599 at the arm naming it. That is the whole enforcement, and it is the compiler’s: a
derive cannot see the upstream declaration, and a table of upstream names kept here would be a
second copy of somebody else’s enum.