pub struct AccountSharedData { /* private fields */ }Expand description
Shared account data that borrows directly from an aligned external buffer until a write requires promotion to owned heap storage.
Higher layers use mutable() to enforce transaction write permissions.
Implementations§
Sourcepub fn cow(&self) -> &CoWAccount
pub fn cow(&self) -> &CoWAccount
Returns a reference to the inner copy-on-write representation.
Sourcepub fn cow_mut(&mut self) -> &mut CoWAccount
pub fn cow_mut(&mut self) -> &mut CoWAccount
Returns mutable access to the inner copy-on-write representation.
Sourcepub fn translate(&mut self)
pub fn translate(&mut self)
Copies a clean borrowed image into the shadow buffer before mutation.
Sourcepub fn owned(&self) -> OwnedAccount
pub fn owned(&self) -> OwnedAccount
Returns an owned copy of the current account state.
Sourcepub fn mutable(&self) -> bool
pub fn mutable(&self) -> bool
Returns whether the current transaction may leave the account modified.
Mutable modes are always accepted. Transient and Closed are accepted
only when this transaction performed the corresponding mode transition.
This is a transaction-final writeback predicate, not permission for a new
program mutation; instruction checks must use AccountMode::mutable.
Sourcepub fn mode(&self) -> AccountMode
pub fn mode(&self) -> AccountMode
Returns the account’s exact lifecycle mode.
Sourcepub fn is(&self, mode: AccountMode) -> bool
pub fn is(&self, mode: AccountMode) -> bool
Returns true when the account is in mode.
Sourcepub fn flags(&self) -> &StateFlags
pub fn flags(&self) -> &StateFlags
Returns the account modifier flags.
Sourcepub fn markers(&self) -> &DirtyMarkers
pub fn markers(&self) -> &DirtyMarkers
Returns the dirty-field markers.
Returns true when the owned buffer has more than one strong reference.
Sourcepub fn data_clone(&self) -> Arc<Vec<u8>> ⓘ
pub fn data_clone(&self) -> Arc<Vec<u8>> ⓘ
Returns a shared owned copy of the current data bytes.
Sourcepub fn extend_from_slice(&mut self, data: &[u8])
pub fn extend_from_slice(&mut self, data: &[u8])
Appends bytes to the account data.
Sourcepub fn set_data_from_slice(&mut self, data: &[u8])
pub fn set_data_from_slice(&mut self, data: &[u8])
Replaces the account data with the provided bytes.
Sourcepub fn set_lifecycle(
&mut self,
mode: AccountMode,
slot: Slot,
) -> Result<(), AccountPatchError>
pub fn set_lifecycle( &mut self, mode: AccountMode, slot: Slot, ) -> Result<(), AccountPatchError>
Applies mode and slot as one validated lifecycle transition.
Mode pairs determine whether slots may stay equal or must advance. Authoritative modes cannot be reapplied, even at a newer slot. Validation precedes translation, so an error leaves account state and dirty markers unchanged.
Sourcepub fn set_flags(&mut self, flags: StateFlags)
pub fn set_flags(&mut self, flags: StateFlags)
Replaces all state flags and marks them dirty when the value changes.
Sourcepub fn new(lamports: u64, space: usize, owner: &Pubkey) -> Self
pub fn new(lamports: u64, space: usize, owner: &Pubkey) -> Self
Creates a new owned shared-data account with zero-filled data.
Sourcepub fn new_ref(lamports: u64, space: usize, owner: &Pubkey) -> Rc<RefCell<Self>>
pub fn new_ref(lamports: u64, space: usize, owner: &Pubkey) -> Rc<RefCell<Self>>
Creates a new shared-data account wrapped in a RefCell.
Sourcepub fn new_rent_epoch(
lamports: u64,
space: usize,
owner: &Pubkey,
_: Epoch,
) -> Self
pub fn new_rent_epoch( lamports: u64, space: usize, owner: &Pubkey, _: Epoch, ) -> Self
Creates a new shared-data account.
rent_epoch is ignored because this type does not store it.
Creates an owned shared-data account from existing shared bytes.
rent_epoch is ignored because this type does not store it.
Trait Implementations§
Source§fn clone(&self) -> AccountSharedData
fn clone(&self) -> AccountSharedData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more