Skip to main content

Account

Struct Account 

Source
#[repr(C)]
pub struct Account { pub lamports: u64, pub data: Vec<u8>, pub owner: Pubkey, pub executable: bool, pub rent_epoch: Epoch, }
Expand description

An on-chain account with owned data and an explicit rent epoch.

Fields§

§lamports: u64

Lamports in the account.

§data: Vec<u8>

Data held in the account.

§owner: Pubkey

The program that owns this account.

§executable: bool

Whether the account contains executable program data.

§rent_epoch: Epoch

The epoch at which this account next owes rent.

Implementations§

Source§

impl Account

Source

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

Creates a new account with zero-filled data.

Source

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

Creates a new account wrapped in a RefCell.

Source

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

Creates a new account with an explicit rent epoch.

Trait Implementations§

Source§

impl Account for Account

Source§

fn get(&mut self) -> (&mut u64, &mut [u8], &Pubkey, bool)

Source§

impl Clone for Account

Source§

fn clone(&self) -> Account

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 Account

Source§

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

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

impl Default for Account

Source§

fn default() -> Account

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

impl Eq for Account

Source§

impl From<Account> for OwnedAccount

Source§

fn from(value: Account) -> Self

Converts to this type from the input type.
Source§

impl From<Account> for AccountBuilder

Source§

fn from(value: Account) -> Self

Converts to this type from the input type.
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 PartialEq for Account

Source§

fn eq(&self, other: &Account) -> 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 Account

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 StructuralPartialEq for Account

Source§

impl WritableAccount for Account

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: 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<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.