Skip to main content

SegmentRegistry

Struct SegmentRegistry 

Source
pub struct SegmentRegistry<'a> { /* private fields */ }
Expand description

Read-only view over a segmented account’s registry.

The registry lives right after the 16-byte AccountHeader.

Implementations§

Source§

impl<'a> SegmentRegistry<'a>

Source

pub fn from_account( account_data: &'a [u8], ) -> Result<SegmentRegistry<'a>, ProgramError>

Parse a segment registry from full account data.

Expects account data starting from byte 0 (including AccountHeader).

Source

pub fn segment_count(&self) -> usize

Number of segments in this account.

Source

pub fn data_region_offset(&self) -> usize

Where segment data begins (after all entries).

Source

pub fn entry(&self, index: usize) -> Result<&SegmentEntry, ProgramError>

Get a segment entry by index.

Source

pub fn find(&self, id: &[u8; 4]) -> Result<(usize, &SegmentEntry), ProgramError>

Find a segment by its ID.

Source

pub fn segment_data(&self, id: &[u8; 4]) -> Result<&'a [u8], ProgramError>

Get the raw data slice for a segment by ID.

Source

pub fn segment_overlay<T>(&self, id: &[u8; 4]) -> Result<&'a T, ProgramError>
where T: Pod + FixedLayout,

Get a typed overlay for a segment by ID.

Source

pub fn iter(&self) -> SegmentIter<'a>

Iterate over all segment entries.

Source

pub fn registry_size(&self) -> usize

Total bytes consumed by the registry (header + all entries).

Source

pub const fn required_account_size( header_size: usize, segment_count: usize, total_segment_data: usize, ) -> usize

Compute required account size for given segment specs.

specs is (segment_data_size,) per segment.

Auto Trait Implementations§

§

impl<'a> Freeze for SegmentRegistry<'a>

§

impl<'a> RefUnwindSafe for SegmentRegistry<'a>

§

impl<'a> Send for SegmentRegistry<'a>

§

impl<'a> Sync for SegmentRegistry<'a>

§

impl<'a> Unpin for SegmentRegistry<'a>

§

impl<'a> UnsafeUnpin for SegmentRegistry<'a>

§

impl<'a> UnwindSafe for SegmentRegistry<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.