Skip to main content

Module segment

Module segment 

Source
Expand description

Runtime-local segment primitive.

Segment stores an absolute byte offset and size in two u32 fields. It is Copy, const-constructable, and carries no field name. The corresponding hopper_core::segment_map::StaticSegment adds a name for schema and tooling use.

§Design

Generated accessors can embed a Segment constant next to their layout metadata:

  • macros emit const BALANCE: Segment = Segment::body(0, 8);
  • call sites read account.segment_mut_const::<u64>(&mut b, BALANCE)?
  • the compiler can propagate the constant through bounds checks and pointer arithmetic.

Segment never appears in an on-chain layout, it is a compile-time description only. Use hopper_core::account::SegmentDescriptor for bytes that travel on the wire.

Structs§

FieldCapability
Zero-sized field capability: type, byte offset, semantic role, and policy.
Segment
Compile-time descriptor of a typed byte range inside an account.
TypedSegment
Compile-time typed segment descriptor: T is the overlay type, OFFSET is the absolute byte offset from the start of account data. Zero-sized.

Constants§

FIELD_POLICY_AUTHORITY_GATED
Field mutations should be gated by an admin or authority proof.
FIELD_POLICY_CHECKED_MATH
Field mutations should use checked arithmetic.
FIELD_POLICY_IMMUTABLE_AFTER_INIT
Field is intended to become immutable after initialization.
FIELD_ROLE_AUTHORITY
Field carries authority or signer identity semantics.
FIELD_ROLE_BALANCE
Field carries accounting or balance semantics.
FIELD_ROLE_DATA
Generic field role for account field capability descriptors.
FIELD_ROLE_VERSION
Field carries migration/versioning semantics.