solana_sdk::transaction_context

Struct BorrowedAccount

Source
pub struct BorrowedAccount<'a> { /* private fields */ }
Expand description

Shared account borrowed from the TransactionContext and an InstructionContext.

Implementations§

Source§

impl<'a> BorrowedAccount<'a>

Source

pub fn get_index_in_transaction(&self) -> usize

Returns the index of this account (transaction wide)

Source

pub fn get_key(&self) -> &Pubkey

Returns the public key of this account (transaction wide)

Source

pub fn get_owner(&self) -> &Pubkey

Returns the owner of this account (transaction wide)

Source

pub fn set_owner(&mut self, pubkey: &[u8]) -> Result<(), InstructionError>

Assignes the owner of this account (transaction wide)

Source

pub fn get_lamports(&self) -> u64

Returns the number of lamports of this account (transaction wide)

Source

pub fn set_lamports(&mut self, lamports: u64) -> Result<(), InstructionError>

Overwrites the number of lamports of this account (transaction wide)

Source

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

Adds lamports to this account (transaction wide)

Source

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

Subtracts lamports from this account (transaction wide)

Source

pub fn get_data(&self) -> &[u8]

Returns a read-only slice of the account data (transaction wide)

Source

pub fn get_data_mut(&mut self) -> Result<&mut [u8], InstructionError>

Returns a writable slice of the account data (transaction wide)

Source

pub fn set_data(&mut self, data: &[u8]) -> Result<(), InstructionError>

Overwrites the account data and size (transaction wide)

Source

pub fn set_data_length( &mut self, new_length: usize, ) -> Result<(), InstructionError>

Resizes the account data (transaction wide)

Fills it with zeros at the end if is extended or truncates at the end otherwise.

Source

pub fn get_state<T: DeserializeOwned>(&self) -> Result<T, InstructionError>

Deserializes the account data into a state

Source

pub fn set_state<T: Serialize>( &mut self, state: &T, ) -> Result<(), InstructionError>

Serializes a state into the account data

Source

pub fn is_executable(&self) -> bool

Returns whether this account is executable (transaction wide)

Source

pub fn set_executable( &mut self, is_executable: bool, ) -> Result<(), InstructionError>

Configures whether this account is executable (transaction wide)

Source

pub fn get_rent_epoch(&self) -> u64

Returns the rent epoch of this account (transaction wide)

Source

pub fn is_signer(&self) -> bool

Returns whether this account is a signer (instruction wide)

Source

pub fn is_writable(&self) -> bool

Returns whether this account is writable (instruction wide)

Source

pub fn is_owned_by_current_program(&self) -> bool

Returns true if the owner of this account is the current InstructionContexts last program (instruction wide)

Source

pub fn can_data_be_changed(&self) -> Result<(), InstructionError>

Returns an error if the account data can not be mutated by the current program

Source

pub fn can_data_be_resized( &self, new_length: usize, ) -> Result<(), InstructionError>

Returns an error if the account data can not be resized to the given length

Trait Implementations§

Source§

impl<'a> Debug for BorrowedAccount<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for BorrowedAccount<'a>

§

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§

Source§

impl<T> AbiExample for T

Source§

default fn example() -> T

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> 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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V