Expand description
Account memory architecture.
Hopper supports four account memory styles:
- Fixed Layout – Classic zero-copy
#[repr(C)]overlay with a 16-byte header. - Overlay Layout – Multiple typed views over different regions of one account.
- Segmented Layout – Fixed prefix + dynamic typed segments with a segment table.
- Arena Layout – Accounts as typed storage arenas (slab allocators, ring buffers).
All styles share the same 16-byte header format for self-description.
Re-exports§
pub use registry::segment_id;pub use registry::SegmentEntry;pub use registry::SegmentId;pub use registry::SegmentRegistry;pub use registry::SegmentRegistryMut;pub use registry::MAX_REGISTRY_SEGMENTS;pub use registry::REGISTRY_HEADER_SIZE;pub use registry::REGISTRY_OFFSET;pub use registry::SEGMENT_ENTRY_SIZE;pub use registry::SEG_FLAG_DYNAMIC;pub use registry::SEG_FLAG_FROZEN;pub use registry::SEG_FLAG_LOCKED;pub use segment_role::SegmentRole;pub use segment_role::SEG_ROLE_AUDIT;pub use segment_role::SEG_ROLE_CACHE;pub use segment_role::SEG_ROLE_CORE;pub use segment_role::SEG_ROLE_EXTENSION;pub use segment_role::SEG_ROLE_INDEX;pub use segment_role::SEG_ROLE_JOURNAL;pub use segment_role::SEG_ROLE_SHARD;
Modules§
- registry
- Segmented Accounts for Hopper.
- segment_
role - Segment roles – typed semantic classification for account segments.
Structs§
- Account
Header - The 16-byte account header, overlay-safe.
- Account
Reader - Header-aware read-only account reader.
- Data
Writer - Sequential write cursor over a mutable byte slice.
- Dynamic
View - An inline dynamic view that caches offsets for O(1) field access.
- Dynamic
View Mut - Mutable inline dynamic view for writing dynamic fields.
- Realloc
Guard - Per-instruction realloc budget guard.
- Segment
Descriptor - A single segment descriptor.
- Segment
Slice - Type-safe immutable slice over a segment’s elements.
- Segment
Slice Mut - Type-safe mutable slice over a segment’s elements.
- Segment
Table - Read-only segment table.
- Segment
Table Mut - Mutable segment table.
- Slice
Cursor - Sequential read cursor over a byte slice.
- Verified
Account - Immutable verified account – proof that validation passed.
- Verified
Account Mut - Mutable verified account – proof that validation passed, with write access.
Constants§
- CLOSE_
SENTINEL - Sentinel byte written to byte 0 when an account is closed. Prevents account revival attacks.
- HEADER_
FORMAT - Header format version. Bump only if the header wire format itself changes.
- HEADER_
LEN - Header length in bytes.
- MAX_
SEGMENTS - Maximum number of segments per account.
- SEGMENT_
DESC_ SIZE - Size of one segment descriptor in bytes.
Traits§
- Fixed
Layout - Trait for types with a compile-time known wire size.
- Pod
- Marker for types that can be safely overlaid on raw account bytes.
Functions§
- cast_
unchecked ⚠ - Raw unchecked cast from bytes to an immutable reference.
- cast_
unchecked_ ⚠mut - Raw unchecked cast from bytes to a mutable reference.
- check_
header - Validate the header against expected values.
- overlay
- Overlay immutable reference to a Pod type at the start of a byte slice.
- overlay_
mut - Overlay mutable reference to a Pod type at the start of a byte slice.
- pod_
from_ bytes - Zero-copy cast from bytes to an immutable reference.
- pod_
from_ bytes_ mut - Zero-copy cast from bytes to a mutable reference.
- pod_
read - Copy a Pod value from bytes (alignment-safe).
- pod_
write - Write a Pod value to bytes (alignment-safe).
- read_
discriminator - Read the discriminator byte from raw account data.
- read_
dynamic_ u8 - Read a u8-prefixed dynamic field: returns (data_slice, next_offset).
- read_
dynamic_ u16 - Read a u16-prefixed dynamic field.
- read_
dynamic_ u32 - Read a u32-prefixed dynamic field.
- read_
header_ flags - Read the flags field as
u16. - read_
layout_ id - Read the 8-byte layout_id.
- read_
version - Read the version byte.
- safe_
close - Safely close an account by draining all lamports to
destination. - safe_
close_ with_ sentinel - Close with sentinel – writes
CLOSE_SENTINELto byte 0 after zeroing. - safe_
realloc - Reallocate an account to a new size.
- write_
dynamic_ u8 - Write a u8-prefixed dynamic field. Returns next offset after written data.
- write_
dynamic_ u16 - Write a u16-prefixed dynamic field.
- write_
dynamic_ u32 - Write a u32-prefixed dynamic field.
- write_
header - Write a complete header to the beginning of
data. - zero_
init - Zero-initialize a byte slice. Must be called before
write_header.