Expand description
Unified zero-copy trait family.
This module consolidates Pod, FixedLayout, Projectable, SafeProjectable,
LayoutContract, header metadata, and schema export into one
coherent trait stack. This module delivers the foundation:
-
ZeroCopy, the canonical “safe to overlay on raw bytes” marker. Equivalent-in-contract toPod, using Hopper’s ownedPod/Zeroableproof layer. A blanket implementation coversPodtypes that also carry Hopper’s sealed marker, including layouts emitted by Hopper’s macros. -
WireLayout, aZeroCopytype whose wire size issize_of::<Self>()under the current blanket implementation. -
AccountLayout, aWireLayoutthat also carries Hopper’s account header identity (disc, version, wire fingerprint, schema epoch, type offset). This is the top-level account-layout trait, with an explicit member list so the contract is frozen-in-place for migrations and client generation.
§Why three traits, not one
The layering mirrors a real capability hierarchy. Every account
layout is a wire layout; every wire layout is zero-copy; but not
every zero-copy type is a full account layout (WireU64, WireBool,
TypedAddress<T> are zero-copy but carry no header). Splitting
the traits lets generic helpers demand just what they need.
§Relation to LayoutContract
The existing crate::layout::LayoutContract trait predates this
module. LayoutContract and AccountLayout intentionally overlap:
both describe “a Hopper layout with disc/version/layout_id”.
AccountLayout presents the same identity through a unified trait stack.
A blanket implementation covers types that implement both
LayoutContract and ZeroCopy.
Traits§
- Account
Layout - Hopper account layout identity, the top of the unified trait stack.
- Wire
Layout - A
ZeroCopytype with a compile-time-known wire size. - Zero
Copy - Canonical marker for types that may be overlaid on raw bytes.