Skip to main content

AccountLayout

Trait AccountLayout 

Source
pub trait AccountLayout: WireLayout {
    const DISC: u8;
    const VERSION: u8;
    const WIRE_FINGERPRINT: u64;
    const TYPE_OFFSET: usize;
    const SCHEMA_EPOCH: u32 = 1;

    // Provided method
    fn required_len() -> usize { ... }
}
Expand description

Hopper account layout identity, the top of the unified trait stack.

This is the audit-blessed trait: its member list matches the PDF’s “proposed trait model” section exactly, so Hopper’s long-term ABI story is anchored in the vocabulary the audit uses.

WIRE_FINGERPRINT is the first 8 bytes of the canonical SHA-256 wire descriptor (see hopper_macros_proc::state::layout_id_bytes) reinterpreted as a little-endian u64, so the runtime can compare against the on-account header byte-for-byte.

SCHEMA_EPOCH defaults to 1; programs that publish later epochs via their on-chain manifest bump it to signal a version transition.

Required Associated Constants§

Source

const DISC: u8

On-chain discriminator (header byte 0).

Source

const VERSION: u8

Layout version (header byte 1).

Source

const WIRE_FINGERPRINT: u64

Canonical wire fingerprint (header bytes 4..12, little-endian).

Source

const TYPE_OFFSET: usize

Offset at which Self starts inside the account buffer. 0 for header-inclusive layouts, HEADER_LEN for body-only.

Provided Associated Constants§

Source

const SCHEMA_EPOCH: u32 = 1

Schema-evolution epoch (header bytes 12..16).

Provided Methods§

Source

fn required_len() -> usize

Total data length an account must carry to hold Self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: LayoutContract + ZeroCopy> AccountLayout for T

Source§

const DISC: u8 = <T as LayoutContract>::DISC

Source§

const VERSION: u8 = <T as LayoutContract>::VERSION

Source§

const WIRE_FINGERPRINT: u64

Source§

const SCHEMA_EPOCH: u32 = 1

Source§

const TYPE_OFFSET: usize = <T as LayoutContract>::TYPE_OFFSET