Struct solana_sdk::transaction_context::BorrowedAccount
source · [−]pub struct BorrowedAccount<'a> { /* private fields */ }
Expand description
Shared account borrowed from the TransactionContext and an InstructionContext.
Implementations
sourceimpl<'a> BorrowedAccount<'a>
impl<'a> BorrowedAccount<'a>
sourcepub fn get_index_in_transaction(&self) -> usize
pub fn get_index_in_transaction(&self) -> usize
Returns the index of this account (transaction wide)
sourcepub fn get_index_in_instruction(&self) -> usize
pub fn get_index_in_instruction(&self) -> usize
Returns the index of this account (instruction wide)
sourcepub fn set_owner(&mut self, pubkey: &[u8])
pub fn set_owner(&mut self, pubkey: &[u8])
Assignes the owner of this account (transaction wide)
sourcepub fn get_lamports(&self) -> u64
pub fn get_lamports(&self) -> u64
Returns the number of lamports of this account (transaction wide)
sourcepub fn set_lamports(&mut self, lamports: u64)
pub fn set_lamports(&mut self, lamports: u64)
Overwrites the number of lamports of this account (transaction wide)
sourcepub fn checked_add_lamports(
&mut self,
lamports: u64
) -> Result<(), InstructionError>
pub fn checked_add_lamports(
&mut self,
lamports: u64
) -> Result<(), InstructionError>
Adds lamports to this account (transaction wide)
sourcepub fn checked_sub_lamports(
&mut self,
lamports: u64
) -> Result<(), InstructionError>
pub fn checked_sub_lamports(
&mut self,
lamports: u64
) -> Result<(), InstructionError>
Subtracts lamports from this account (transaction wide)
sourcepub fn get_data(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn get_data(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a read-only slice of the account data (transaction wide)
sourcepub fn get_data_mut(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn get_data_mut(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a writable slice of the account data (transaction wide)
sourcepub fn set_data(&mut self, data: &[u8])
pub fn set_data(&mut self, data: &[u8])
Overwrites the account data and size (transaction wide)
sourcepub fn set_data_length(&mut self, new_len: usize)
pub fn set_data_length(&mut self, new_len: usize)
Resizes the account data (transaction wide)
Fills it with zeros at the end if is extended or truncates at the end otherwise.
sourcepub fn get_state<T: DeserializeOwned>(&self) -> Result<T, InstructionError>
pub fn get_state<T: DeserializeOwned>(&self) -> Result<T, InstructionError>
Deserializes the account data into a state
sourcepub fn set_state<T: Serialize>(
&mut self,
state: &T
) -> Result<(), InstructionError>
pub fn set_state<T: Serialize>(
&mut self,
state: &T
) -> Result<(), InstructionError>
Serializes a state into the account data
sourcepub fn is_executable(&self) -> bool
pub fn is_executable(&self) -> bool
Returns whether this account is executable (transaction wide)
sourcepub fn set_executable(&mut self, is_executable: bool)
pub fn set_executable(&mut self, is_executable: bool)
Configures whether this account is executable (transaction wide)
sourcepub fn get_rent_epoch(&self) -> u64
pub fn get_rent_epoch(&self) -> u64
Returns the rent epoch of this account (transaction wide)
sourcepub fn is_writable(&self) -> bool
pub fn is_writable(&self) -> bool
Returns whether this account is writable (instruction wide)
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for BorrowedAccount<'a>
impl<'a> !Send for BorrowedAccount<'a>
impl<'a> !Sync for BorrowedAccount<'a>
impl<'a> Unpin for BorrowedAccount<'a>
impl<'a> !UnwindSafe for BorrowedAccount<'a>
Blanket Implementations
sourceimpl<T> AbiExample for T
impl<T> AbiExample for T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more