#[repr(C)]pub struct Segment {
pub offset: u32,
pub size: u32,
}Expand description
Compile-time descriptor of a typed byte range inside an account.
The u32 fields match Hopper’s segment metadata encoding and keep the
descriptor eight bytes wide.
Fields§
§offset: u32Absolute byte offset from the start of account data (includes the 16-byte Hopper header). This is what the access primitives want, so storing it absolute avoids a runtime addition.
size: u32Byte size of the segment.
Implementations§
Source§impl Segment
impl Segment
Sourcepub const fn new(offset: u32, size: u32) -> Self
pub const fn new(offset: u32, size: u32) -> Self
Construct a segment from an absolute offset (measured from the start of account data, including the Hopper header).
Sourcepub const fn body(body_offset: u32, size: u32) -> Self
pub const fn body(body_offset: u32, size: u32) -> Self
Construct a segment from a body-relative offset (offset measured
past the 16-byte Hopper header). This is the form that macros
most often emit: #[hopper::state] computes field offsets
relative to the struct body, and body-relative is what
SegmentMap::SEGMENTS stores.
Sourcepub const fn end(&self) -> u64
pub const fn end(&self) -> u64
One-past-the-end byte offset, widened to u64 so offset + size
cannot wrap before containment and overlap comparisons.
Sourcepub const fn contained_in(&self, container: &Segment) -> bool
pub const fn contained_in(&self, container: &Segment) -> bool
Whether this segment is contained fully within container.