Skip to main content

SegmentedAccount

Struct SegmentedAccount 

Source
pub struct SegmentedAccount<'a, T: Pod + FixedLayout + HopperLayout> { /* private fields */ }
Expand description

A segmented account with role-aware region access.

The account data is divided into a segment registry header followed by typed segments. Each segment has a role (Core, Extension, Journal, etc.) and can be accessed individually.

Implementations§

Source§

impl<'a, T: Pod + FixedLayout + HopperLayout> SegmentedAccount<'a, T>

Source

pub fn from_account( account: &'a AccountView, program_id: &'a Address, ) -> Result<Self, ProgramError>

Construct from an AccountView with header and owner validation.

Source

pub fn registry(&self) -> Result<BorrowedSegmentRegistry<'_>, ProgramError>

Access the segment registry.

Source

pub fn segment_by_index( &self, index: usize, ) -> Result<Ref<'_, [u8]>, ProgramError>

Read a segment’s raw bytes by index.

Source

pub fn segment_data( &self, id: &SegmentId, ) -> Result<Ref<'_, [u8]>, ProgramError>

Read a segment’s data by its 4-byte ID.

Source

pub fn segment_by_index_mut( &self, index: usize, ) -> Result<RefMut<'_, [u8]>, ProgramError>

Read a segment’s raw bytes mutably by index.

Source

pub fn address(&self) -> &Address

The account’s address.

Source

pub fn to_account_view(&self) -> &'a AccountView

The underlying AccountView.

Auto Trait Implementations§

§

impl<'a, T> Freeze for SegmentedAccount<'a, T>

§

impl<'a, T> RefUnwindSafe for SegmentedAccount<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for SegmentedAccount<'a, T>
where T: Send,

§

impl<'a, T> Sync for SegmentedAccount<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for SegmentedAccount<'a, T>
where T: Unpin,

§

impl<'a, T> UnsafeUnpin for SegmentedAccount<'a, T>

§

impl<'a, T> UnwindSafe for SegmentedAccount<'a, T>
where T: UnwindSafe,

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.