#[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 Account with data that is stored on chain
Fields§
§lamports: u64
lamports in the account
data: Vec<u8>
data held in this account
owner: Pubkey
the program that owns this account. If executable, the program that loads this account.
executable: bool
this account’s data contains a loaded program (and is now read-only)
rent_epoch: Epoch
the epoch at which this account will next owe rent
Implementations§
Source§impl Account
impl Account
pub fn new(lamports: u64, space: usize, owner: &Pubkey) -> Self
pub fn new_ref(lamports: u64, space: usize, owner: &Pubkey) -> Rc<RefCell<Self>>
pub fn new_data<T: Serialize>( lamports: u64, state: &T, owner: &Pubkey, ) -> Result<Self, Error>
Available on crate feature
bincode
only.pub fn new_ref_data<T: Serialize>( lamports: u64, state: &T, owner: &Pubkey, ) -> Result<RefCell<Self>, Error>
Available on crate feature
bincode
only.pub fn new_data_with_space<T: Serialize>( lamports: u64, state: &T, space: usize, owner: &Pubkey, ) -> Result<Self, Error>
Available on crate feature
bincode
only.pub fn new_ref_data_with_space<T: Serialize>( lamports: u64, state: &T, space: usize, owner: &Pubkey, ) -> Result<RefCell<Self>, Error>
Available on crate feature
bincode
only.pub fn new_rent_epoch( lamports: u64, space: usize, owner: &Pubkey, rent_epoch: Epoch, ) -> Self
pub fn deserialize_data<T: DeserializeOwned>(&self) -> Result<T, Error>
Available on crate feature
bincode
only.pub fn serialize_data<T: Serialize>(&mut self, state: &T) -> Result<(), Error>
Available on crate feature
bincode
only.Trait Implementations§
Source§impl Account for Account
impl Account for Account
Return the information required to construct an AccountInfo
. Used by the
AccountInfo
conversion implementations.
Source§impl<'de> Deserialize<'de> for Account
impl<'de> Deserialize<'de> for Account
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§fn from(other: AccountSharedData) -> Self
fn from(other: AccountSharedData) -> Self
Converts to this type from the input type.
Source§impl ReadableAccount for Account
impl ReadableAccount for Account
Source§impl<T> StateMut<T> for Accountwhere
T: Serialize + DeserializeOwned,
Available on crate feature bincode
only.
impl<T> StateMut<T> for Accountwhere
T: Serialize + DeserializeOwned,
Available on crate feature
bincode
only.Source§impl WritableAccount for Account
impl WritableAccount for Account
fn set_lamports(&mut self, lamports: u64)
fn data_as_mut_slice(&mut self) -> &mut [u8] ⓘ
fn set_owner(&mut self, owner: Pubkey)
fn copy_into_owner_from_slice(&mut self, source: &[u8])
fn set_executable(&mut self, executable: bool)
fn set_rent_epoch(&mut self, epoch: Epoch)
fn create( lamports: u64, data: Vec<u8>, owner: Pubkey, executable: bool, rent_epoch: Epoch, ) -> Self
fn checked_add_lamports(&mut self, lamports: u64) -> Result<(), LamportsError>
fn checked_sub_lamports(&mut self, lamports: u64) -> Result<(), LamportsError>
fn saturating_add_lamports(&mut self, lamports: u64)
fn saturating_sub_lamports(&mut self, lamports: u64)
impl Eq for Account
impl StructuralPartialEq for Account
Auto Trait Implementations§
impl Freeze for Account
impl RefUnwindSafe for Account
impl Send for Account
impl Sync for Account
impl Unpin for Account
impl UnwindSafe for Account
Blanket Implementations§
Source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, _digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Source§impl<T> AbiEnumVisitor for Twhere
T: Serialize + AbiExample,
impl<T> AbiEnumVisitor for Twhere
T: Serialize + AbiExample,
default fn visit_for_abi( &self, digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more