pub struct SegmentTable<'a> { /* private fields */ }Expand description
Immutable view over the segment table region of an account.
The table starts at a known offset (typically right after the fixed
prefix) and contains segment_count descriptors of 8 bytes each.
Implementations§
Source§impl<'a> SegmentTable<'a>
impl<'a> SegmentTable<'a>
Sourcepub fn from_bytes(
data: &'a [u8],
segment_count: usize,
) -> Result<Self, ProgramError>
pub fn from_bytes( data: &'a [u8], segment_count: usize, ) -> Result<Self, ProgramError>
Parse a segment table from data.
data should start at the first descriptor byte.
segment_count must be ≤ MAX_SEGMENTS.
Sourcepub fn descriptor(
&self,
index: usize,
) -> Result<SegmentDescriptor, ProgramError>
pub fn descriptor( &self, index: usize, ) -> Result<SegmentDescriptor, ProgramError>
Get the descriptor at index.
Sourcepub fn validate(
&self,
account_len: usize,
expected_sizes: &[u16],
min_offset: usize,
) -> Result<(), ProgramError>
pub fn validate( &self, account_len: usize, expected_sizes: &[u16], min_offset: usize, ) -> Result<(), ProgramError>
Validate that all segments are well-formed within account_len bytes.
min_offset is the earliest byte at which segment data may start
(typically DATA_START_OFFSET - after the fixed prefix + table).
This prevents segment data from overlapping the fixed prefix or
the segment table itself.
Checks:
- Element size matches
expected_sizes[i](if provided). - Segment data fits within the account.
- No segment data starts before
min_offset. - No two segments overlap.
- All segments are ordered by offset.
Auto Trait Implementations§
impl<'a> Freeze for SegmentTable<'a>
impl<'a> RefUnwindSafe for SegmentTable<'a>
impl<'a> Send for SegmentTable<'a>
impl<'a> Sync for SegmentTable<'a>
impl<'a> Unpin for SegmentTable<'a>
impl<'a> UnsafeUnpin for SegmentTable<'a>
impl<'a> UnwindSafe for SegmentTable<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more