Skip to main content

Module zerocopy

Module zerocopy 

Source
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 to Pod, using Hopper’s owned Pod / Zeroable proof layer. A blanket implementation covers Pod types that also carry Hopper’s sealed marker, including layouts emitted by Hopper’s macros.

  • WireLayout, a ZeroCopy type whose wire size is size_of::<Self>() under the current blanket implementation.

  • AccountLayout, a WireLayout that 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§

AccountLayout
Hopper account layout identity, the top of the unified trait stack.
WireLayout
A ZeroCopy type with a compile-time-known wire size.
ZeroCopy
Canonical marker for types that may be overlaid on raw bytes.