Skip to main content

AccountSharedData

Struct AccountSharedData 

Source
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§

Source§

impl AccountSharedData

Source

pub fn cow(&self) -> &CoWAccount

Returns a reference to the inner copy-on-write representation.

Source

pub fn cow_mut(&mut self) -> &mut CoWAccount

Returns mutable access to the inner copy-on-write representation.

Source

pub fn slot(&self) -> Slot

Returns the account’s on-chain slot.

Source

pub fn translate(&mut self)

Copies a clean borrowed image into the shadow buffer before mutation.

Source

pub fn owned(&self) -> OwnedAccount

Returns an owned copy of the current account state.

Source

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.

Source

pub fn mode(&self) -> AccountMode

Returns the account’s exact lifecycle mode.

Source

pub fn is(&self, mode: AccountMode) -> bool

Returns true when the account is in mode.

Source

pub fn flags(&self) -> &StateFlags

Returns the account modifier flags.

Source

pub fn markers(&self) -> &DirtyMarkers

Returns the dirty-field markers.

Source

pub fn is_shared(&self) -> bool

Returns true when the owned buffer has more than one strong reference.

Source

pub fn dirty(&self) -> bool

Returns true if any field has been modified.

Source

pub fn capacity(&self) -> usize

Returns the current data capacity.

Source

pub fn data_clone(&self) -> Arc<Vec<u8>>

Returns a shared owned copy of the current data bytes.

Source

pub fn resize(&mut self, len: usize, val: u8)

Resizes the account data.

Source

pub fn extend_from_slice(&mut self, data: &[u8])

Appends bytes to the account data.

Source

pub fn set_data_from_slice(&mut self, data: &[u8])

Replaces the account data with the provided bytes.

Source

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.

Source

pub fn set_flags(&mut self, flags: StateFlags)

Replaces all state flags and marks them dirty when the value changes.

Source

pub fn new(lamports: u64, space: usize, owner: &Pubkey) -> Self

Creates a new owned shared-data account with zero-filled data.

Source

pub fn new_ref(lamports: u64, space: usize, owner: &Pubkey) -> Rc<RefCell<Self>>

Creates a new shared-data account wrapped in a RefCell.

Source

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.

Source

pub fn create_from_existing_shared_data( lamports: u64, data: Arc<Vec<u8>>, owner: Pubkey, executable: bool, _: Epoch, ) -> Self

Creates an owned shared-data account from existing shared bytes.

rent_epoch is ignored because this type does not store it.

Trait Implementations§

Source§

impl Clone for AccountSharedData

Source§

fn clone(&self) -> AccountSharedData

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AccountSharedData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AccountSharedData

Source§

fn default() -> AccountSharedData

Returns the “default value” for a type. Read more
Source§

impl Deref for AccountSharedData

Source§

type Target = AccountCore

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for AccountSharedData

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Eq for AccountSharedData

Source§

impl From<Account> for AccountSharedData

Converts a plain Account into shared data.

Source§

fn from(value: Account) -> Self

Converts to this type from the input type.
Source§

impl From<AccountSharedData> for Account

Source§

fn from(other: AccountSharedData) -> Self

Converts to this type from the input type.
Source§

impl From<AccountSharedData> for AccountBuilder

Source§

fn from(value: AccountSharedData) -> Self

Converts to this type from the input type.
Source§

impl From<BorrowedAccount> for AccountSharedData

Wraps a borrowed account in AccountSharedData.

Source§

fn from(value: BorrowedAccount) -> Self

Converts to this type from the input type.
Source§

impl From<OwnedAccount> for AccountSharedData

Wraps an owned account in AccountSharedData.

Source§

fn from(value: OwnedAccount) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for AccountSharedData

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<OwnedAccount> for AccountSharedData

Source§

fn eq(&self, other: &OwnedAccount) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl ReadableAccount for AccountSharedData

Source§

fn lamports(&self) -> u64

Returns the lamport balance.
Source§

fn data(&self) -> &[u8]

Returns the account data.
Source§

fn owner(&self) -> &Pubkey

Returns the account owner.
Source§

fn executable(&self) -> bool

Returns whether the account is executable.
Source§

fn rent_epoch(&self) -> Epoch

Returns the rent epoch view for this account.
Source§

impl Sync for AccountSharedData

We only access AccountSharedData via transaction lock in the execution layer or with a SeqLock semantics outside of execution

Source§

impl WritableAccount for AccountSharedData

Source§

fn set_lamports(&mut self, lamports: u64)

Replaces the lamport balance.
Source§

fn data_as_mut_slice(&mut self) -> &mut [u8]

Returns mutable access to the account data.
Source§

fn set_owner(&mut self, owner: Pubkey)

Replaces the owner.
Source§

fn copy_into_owner_from_slice(&mut self, source: &[u8])

Copies 32 raw bytes into the owner pubkey.
Source§

fn set_executable(&mut self, executable: bool)

Sets the executable flag.
Source§

fn set_rent_epoch(&mut self, _: Epoch)

Sets the rent epoch view if the implementation stores one. Read more
Source§

fn checked_add_lamports(&mut self, lamports: u64) -> Result<(), LamportsError>

Adds lamports or returns an overflow error.
Source§

fn checked_sub_lamports(&mut self, lamports: u64) -> Result<(), LamportsError>

Subtracts lamports or returns an underflow error.
Source§

fn saturating_add_lamports(&mut self, lamports: u64)

Adds lamports and saturates on overflow.
Source§

fn saturating_sub_lamports(&mut self, lamports: u64)

Subtracts lamports and saturates on underflow.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.