Expand description
The VOCABULARY face: what a unit-variant enum expands into.
A vocabulary is not a node. It owns no storage, subscribes to nothing and carries no key — it is a VALUE a record’s column holds, and the whole of what it needs is the rows that say how a column of it is read, the rows that say how one is stored, and the words its faces spell it as.
§Storage is MACHINE-FACING, and the wire is not
A database stores the DISCRIMINANT and a schema shows the NAME, and neither is a knob a declaration has to reach for: a column exists for a machine and a wire face exists for a person, so those are the defaults and a per-backend block is what overrides one.
#[derive(Debug, Clone, Copy, PartialEq, Eq, ingraph::Enum)]
#[repr(u8)]
pub enum Grade { Low, High, Archived = 9 }stores 0, 1 and 9 in every database this build compiled, shows LOW, HIGH and
ARCHIVED on the wire, and declares none of it. The crossing is what joins the two: a filter’s
operand arrives as the enum, so the user’s text is translated at the FILTER and never reaches an
integer column as text.
§The width follows #[repr(…)], through the house carrier rules
#[repr(u8)] is a u8 column. What that means per dialect is not this module’s invention: the
framework’s own carrier table already widens where a dialect has no such type — u8 and i8
bind as SMALLINT on Postgres, u16 as INT, u32 as BIGINT — and a vocabulary’s rows take
the same widening, which is why they are per-backend rather than one dialect-generic row.
Absent a #[repr(…)], the width is i64, and that is measured rather than picked for room. A
fieldless enum with no repr hint has discriminants of type isize, so Grade::High = 3_000_000_000
is a legal declaration on every 64-bit target; a narrower default would store it through an as
cast that silently wraps, and a wrong number in somebody’s database is exactly what a DEFAULT must
not be able to produce. i64 is also native on all three dialects — SQLite’s INTEGER,
Postgres’s and MySQL’s BIGINT — so the safe width costs no widening anywhere.
§The set of rows, measured against what a working enum column actually needs
| impl | who demands it | gated |
|---|---|---|
EnumFilterMarker | the column’s FILTER — EnumMarker<T> resolves through it | no |
DefaultMarker | the INFERENCE, so a column needs no enum word to be read as one | no |
CursorValue | the KEYSET cursor, which every persisted column is audited for | no |
sqlx::Type | the emitted FromRow, once per column | per backend |
sqlx::Decode | the emitted FromRow, once per column | per backend |
sqlx::Encode | the write side of the same binding — an authority names both directions | per backend |
Carrier | the comparison’s LOWERING, which is what binds an operand into a query | per backend |
The last four are the six-row template the vocabulary’s first round measured, now written once
per COMPILED-IN backend behind crate::model::DatabaseKind’s gate. What a gate makes an
emission mean is ingraph’s crate note, under The four gates: an impl exists per declared ∩
compiled-in backend, and a build without a driver has no impl rather than a deferred one.
ingraph-derive’s tests/enums.rs is where the set is checked: it declares such a column and
drives the whole circle through a live database, so a row that were merely plausible would fail
there rather than pass a token comparison.
§The FACE is hand-emitted, and it is backend-free
is_<variant>, VARIANTS, as_str, one as_<namespace>_str per TEXT face, FromStr over the
canonical namespace and one TryFrom<&…Name> per text face. None of it names a backend, so
none of it rides a gate — what decides whether a namespace has a face is its FORM, since a
backend storing a discriminant has no text for a name type to hold.
No derive_more, and no derive of any kind: the methods are this crate’s emission, so the
expanded code names no foreign path and the errors are the vocabulary’s own.
§The REFUSAL type is the ONE name this expansion puts in the declaring scope, so it is the one
that can be renamed
Everything else sits inside an anonymous const, where it can collide with nothing anybody
wrote. The refusal cannot: it is named in signatures a caller writes — FromStr::Err,
TryFrom::Error — so it stands beside the enum, and a scope that already holds a
<Enum>ParseError gets a duplicate definition at a span the declaration cannot edit.
error(rename = "…") is the way out, and it is the ESCAPE from that collision rather than a
spelling preference: the DEFAULT is unchanged, a declaration that names nothing is unaffected,
and a scope with nothing in the way never has to know the knob exists.
Renaming the type does NOT move the sentence it prints. The message names the VOCABULARY —
Codec: no variant answers to this name — because what failed is a parse into the enum, and
the type carrying the refusal is an implementation detail of how that is reported.
§MongoDB is measured and stores NOTHING yet
MongoEnumComparison exists and MongoCarrier is the row that would feed it, so the second
backend is not blocked on a design. What is missing is a lane that can compile the row:
ingraph-derive’s dev-dependency on ingraph carries no mongo, so a MongoDB storage row would
ship with no configuration in this workspace able to build it. Its NAMESPACE is here regardless —
mongo(text) gives a declaration as_mongo_str and TryFrom<&MongoName>, which is exactly
what the hand-written impl MongoCarrier that trait’s doc asks for is written in terms of.
§The wire face rides in the SAME emission, behind the binding gate
[wire] writes it and EnumModel::emit carries it — one organ, one word. There were two
doors and the second was deleted: schema presence is REACHABILITY (an enum no wire type names
never enters an SDL), so a macro was never the gatekeeper the split took it for, and what the
split cost — a silent composition-order trap, two entry points onto one model — was the
coexistence rather than a consequence of it.
The era rule never held that face, and the note that said so was stale. A GraphQL face is a
VENDORED trait impl rather than a framework one — #krate::__private::async_graphql::InputType
IS ::async_graphql::InputType, a third-party trait on a third-party release cadence — and
ingraph-codegen’s own framework_rooted has exempted the vendored segment since the order door
landed. What actually held it was THE WALL: a filter over a declarer’s enum had no InputType,
and the row that supplies it is graphql::filter::r#enum’s single generic impl.
Re-exports§
pub use crate::delegate::Delegate;pub use crate::delegate::DelegateSkin;
Structs§
- Enum
Model - One vocabulary’s declaration, validated.
- Enum
Variant - One variant, with whatever the declaration renamed it to.
- Remote
- The UPSTREAM vocabulary a declaration mirrors, and what it asked to borrow from it.
Enums§
- Escape
- HOW a mirror turns a word its upstream does not name into an upstream value — the three postures
#[ingraph(other)]takes, and the whole of what a mirror’s openness can be. - Integer
Width - The width a vocabulary’s discriminant is stored at — every integer
#[repr(…)]the house’s carrier table can carry, and no other. - Namespace
- One face a vocabulary has: four databases and the wire.
- Storage
Form - What a face spells one variant AS.
Constants§
- TEXT_
FIELD - The field a PROMOTED mirror publishes its own word at.