#[derive(Id)]
{
// Attributes available to this derive:
#[ingraph]
}
derive only.Expand description
Equip an ID WRAPPER — a #[repr(transparent)] type holding one value — with the whole register
an address needs.
#[derive(ingraph::Id)]
#[repr(transparent)]
pub struct TrackId(uuid::Uuid);That is the entire declaration. There is no kit word, no #[derive(Clone, PartialEq, Eq, Hash)]
beside it and no hand-written row after it: the type stands at a record’s #[ingraph(id)], at an
aggregate’s #[ingraph(group)], in a filesystem path, in a SQL column, on a cursor and in a
schema, from this word alone.
§Named for the trait it ADMITS
#[derive(Clone)] gives you Clone; this gives you Id — the sealed key-field
vocabulary, entered through its third admission law. It is deliberately not spelled
#[ingraph(id)]: that word is the RECORD’s, naming which FIELD of a declaration is its address.
§What it writes
| face | mechanism |
|---|---|
DelegatesId | the transparency assertion, upheld BY CONSTRUCTION rather than asserted |
Debug, Clone, PartialEq, Eq, Hash | delegated to the held value |
Display, FromStr | delegated — the canonical spelling is the inner type’s own |
From<Inner>, From<Self> for Inner, From<Self> for String | the conversions, and the crossing a TEXT-column comparison asks for |
CursorValue | delegated — a keyset position |
ColumnKind, Carrier<Db>, Assemble | one column, bound and decoded as canonical TEXT |
ToGraphqlInput, ToGraphqlOutput | the identity crossing and the borrow |
ScalarWire, CompositeFilterMarker, DefaultMarker | the filter reading, over a minted <Name>Wire |
async_graphql::ScalarType | the scalar itself, under this type’s own name |
new, into_inner, as_inner | the constructor and the two readings |
from_ref, from_slice, as_inner_slice | the free views, #[repr(transparent)]’s own dividend |
The roster is a MEASUREMENT and not a wish list: it is what findit’s MediaId and
mediagraph’s VolumeId each hand-wrote, independently, impl for impl.
§THE ONE OBLIGATION ON THE WRAPPED TYPE: a canonical text form
It must implement Display and FromStr, the
latter with a refusal that is an Error. Every row from Display down
spends one or the other — the bind renders, the decode reads back, the scalar does both — and the
storage pair crosses through String rather than through the wrapped type’s own column faces,
which is the road both live registers took and for the reason they took it: ingraph ships no
value-column row for a bare uuid::Uuid to delegate to.
So [u8; N] — a measured member of the vocabulary with neither face — is refused, at the
declaration, naming what is missing. A digest is a perfectly good key and not a text-shaped
value; its road is unsafe impl ingraph::DelegatesId, which asks for no text at all.
§Ord is NOT written, and Copy is the declaration’s own
No id duty reads an order — the stored order is the backend’s reading of the value and the path
segment is the framework’s own rendering — so a device that minted one would be inventing an
order for a type whose author may have refused it. #[derive(PartialOrd, Ord)] beside this word
is how a declaration that wants one says so, and #[derive(Copy)] resolves against the Clone
this device writes.
§THE DOOR HAS NO INVARIANT, and that is a requirement rather than an observation
from_ref views any &Inner as a &Self. A wrapper whose values are a CHECKED SUBSET of its
inner’s therefore does not belong here — take #[derive(ingraph::NewType)] with
scalar(check = "…") or scalar(parse = "…"), where every read path is spent on the door.
§Refusals
A declaration that is not a struct; one whose field is NAMED, or that holds any number of values
but one; one carrying no #[repr(transparent)]; one that is GENERIC. Each is refused by name,
with what to write instead — as is every word #[derive(ingraph::NewType)] carries that this
door does not, pointed at the door that has it.