Skip to main content

borrowed_key

Function borrowed_key 

Source
pub fn borrowed_key(prefix: &EmissionPrefix) -> Ident
Expand description

The FIELD a derived index carries its upstream’s key in — the one field a macro in this family adds to a declaration its author wrote.

The key is not its to mint. A derived index has no id, so Identifiable::id_ref and Transformer::key have nothing in the declaration to answer from; this field is what they answer from, and its TYPE is a projection — <Upstream as Transformer>::Key — so the upstream’s own declaration decides it and re-keying the upstream re-keys every index over it.

It is why the family is attribute macros. A derive is handed a copy and may only append, so a field that is not in the source cannot exist; an attribute macro emits the item in the source’s place, and this is the field it puts there.

§THE FRAME LAW

Every name the framework mints into a declaration’s own namespace wears __ig at the front, and a FIELD wears __ at both ends as well — which is what makes the injection safe rather than merely conventional. ingraph-derive’s fence refuses a declared column inside either namespace, so a user field called __ig_key__ is refused at the declaration and can never be the field this one collides with.

The tail of such a word must not look like _<digits>__. Where a mint is INDEXED the digits fuse into the word — __ig_ord0__, never __ig_ord_0__ — so that the index cannot be read as a separate segment and two schemes cannot produce one name. Nothing minted today is indexed; upstream(…)’s second entry is what will be, one source per key variant, and the law is stated here because here is where a reader of the first mint will look for it.

The frame is EmissionPrefix::framed_ident’s, so the mark is the MODEL’s rather than this crate’s: a declaration a domain framework expanded carries that framework’s injected key, fenced by that framework’s own derive, and the law above holds unchanged one namespace over.