Skip to main content

SegmentRegistryMut

Struct SegmentRegistryMut 

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

Mutable view over a segmented account’s registry.

Implementations§

Source§

impl<'a> SegmentRegistryMut<'a>

Source

pub fn from_account_mut( account_data: &'a mut [u8], ) -> Result<SegmentRegistryMut<'a>, ProgramError>

Parse a mutable segment registry from full account data.

Source

pub fn segment_count(&self) -> usize

Number of segments.

Source

pub fn init( data: &mut [u8], specs: &[([u8; 4], u32, u8)], ) -> Result<(), ProgramError>

Initialize the registry with segment specifications.

specs is (segment_id, data_size, version) per segment. Must be called on a freshly zeroed account.

Source

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

Get a mutable entry by index.

Source

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

Find a segment by ID and return mutable entry.

Source

pub fn segment_data_mut( &mut self, id: &[u8; 4], ) -> Result<&mut [u8], ProgramError>

Get the mutable data slice for a segment by ID.

Returns an error if the segment is locked, frozen, or has an immutable role (Audit). Use [segment_data_mut_unchecked] to bypass role enforcement (e.g., during initial account setup).

Source

pub fn segment_data_mut_unchecked( &mut self, id: &[u8; 4], ) -> Result<&mut [u8], ProgramError>

Get the mutable data slice for a segment without role enforcement.

Use during account initialization when writing to Audit segments before they become immutable. Still checks locked/frozen flags.

Source

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

Get a mutable typed overlay for a segment.

Returns an error if the segment is locked or frozen.

Source

pub fn freeze_segment(&mut self, id: &[u8; 4]) -> Result<(), ProgramError>

Freeze a segment (set frozen flag).

Source

pub fn unfreeze_segment(&mut self, id: &[u8; 4]) -> Result<(), ProgramError>

Unfreeze a segment.

Source

pub fn lock_segment(&mut self, id: &[u8; 4]) -> Result<(), ProgramError>

Lock a segment permanently (cannot be unlocked).

Auto Trait Implementations§

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.