#[repr(C)]pub struct Segment {
pub offset: u32,
pub size: u32,
}Expand description
Compile-time descriptor of a typed byte range inside an account.
Fields are u32 because every Solana account is bounded by
u32::MAX in practice and we want the whole primitive to fit in a
single 64-bit register.
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 contained_in(&self, container: &Segment) -> bool
pub const fn contained_in(&self, container: &Segment) -> bool
Whether this segment is contained fully within container.