Skip to main content

Module remote

Module remote 

Source
Expand description

The REWRITE MODE’s emission — what a declaration means when it WRAPS a foreign type.

The front half is ingraph_derive’s remote module, which owns the item: the fields an author wrote become a MANIFEST and the item the compiler sees becomes #[repr(transparent)] struct X(Remote);. This half is everything that follows from that, and it is one idea repeated: a manifest column is read through the remote’s own accessor and crossed by Into, and a wrapper is built through the remote’s own constructor.

Every other face is UNCHANGED and that is the design. A column carries a name, a type, a projection and its markers whether it was declared or restated, so the row, the filter, the comparison, the order-by and the wire face read exactly what they read before — see RecordModel::remote. What moves is two seams:

seamordinaryrewrite
READ a columnrecord.widthrecord.0.width(), crossed
BUILD the valueSelf { width, … }Self(Remote::new(…).with_…(…))

§The reference family is the LANGUAGE’s guarantee, not a layout claim

Deref, AsRef, Borrow and their mutable halves all hand back &self.0, which is a field access on a 1-tuple. No transmute is written and none is needed; the repr(transparent) on the wrapper is what makes the two types interchangeable to a caller, and the borrow is ordinary Rust either way. The alternative — asserting size and align and transmuting — was refused on soundness: a repr(Rust) layout is not verifiable from outside and offset_of! cannot name a private field of a foreign type.

Borrow<Remote>’s contract — that Eq, Ord and Hash agree between the two — holds for the reason a 1-tuple newtype’s always does: the wrapper’s derives delegate to its one field, and the author’s own #[derive(…)] is forwarded onto the wrapper by the rewrite.

§Deref is the ONLY sound method inheritance, and it is why the wrapper exists

A restatement — the shape derive(Enum)’s mirror mode takes — cannot inherit a method: it holds its own value and the upstream’s is nowhere. A wrapper holds the upstream itself, so Deref is real forwarding and every method the remote has is reachable through it, with no per-method declaration and nothing to keep in step across an upstream release.

§What the compiler checks, and where the caret lands

The manifest is a CLAIM ABOUT AN API — not about a layout, which is unknowable from here — and every part of it is discharged by the compiler at a span this emission puts on the author’s own token:

the claimhow it fails
the remote has an accessor per manifest fieldno method — at the manifest field
its return type crosses to the manifest type[BRIDGE]’s named E0277 — at the manifest field
an identity field’s accessor BORROWSE0308 — at the manifest field
the remote has a constructor of this arityE0061 — at the row conversion
it has a with_… per optional fieldno method — at the manifest field

The identity row is the one asymmetry and it is forced rather than chosen. This framework’s identity seats BORROW — Identifiable::id_ref(&self) -> &Self::Id, and From<&Record> clones a lineage step out of the record — so an identity column has to be reachable as a reference or those seats cannot be served at all, and a value crossed by Into has no address to hand out. A data column has no borrowed seat anywhere and therefore crosses by value. It reads as the accessor law one tier up already reads: identity columns are handled by reference and set at construction, data columns are the ones with a family.

§THE CORE IS SHARED, and the identity seat is the one part of it that is not

Three declarations take remote = "…": entity, record and — bearing no id — fields. What the first two reach through RecordModel and the third reaches directly is the SAME core, written once here as free functions over (subject, remote):

the piecewho emits it
[prelude] — the bridge marker, its blanket impl and the crossing functionall three
[family] — the reference family and the two Fromsall three
[identity_owner] — the clone behind a type parameterthe rungs that BEAR an id

The last row is the split, and it is the tier’s definition rather than a convenience. A fragment has no identity seat to serve, so it never reads an id out of a remote — and emitting the helper anyway would put a warning: function \__ingraph_owned` is never usedin the declaring crate, MEASURED by compiling an unused item inside an anonymous const and readingdead_code` back.