CruiserAccountInfo

Struct CruiserAccountInfo 

Source
pub struct CruiserAccountInfo {
    pub key: &'static Pubkey,
    pub is_signer: bool,
    pub is_writable: bool,
    pub lamports: Rc<RefCell<&'static mut u64>>,
    pub data: Rc<RefCell<&'static mut [u8]>>,
    pub original_data_len: &'static usize,
    pub owner: &'static RefCell<&'static mut Pubkey>,
    pub executable: bool,
    pub rent_epoch: Epoch,
}
Expand description

A custom version of Solana’s AccountInfo that allows for owner changes.

Fields§

§key: &'static Pubkey

The public key of the account.

§is_signer: bool

Whether the account is a signer of the transaction

§is_writable: bool

Whether the account is writable

§lamports: Rc<RefCell<&'static mut u64>>

How many lamports the account has.

§Change Limitations

  • Lamports must not have been created or destroyed by transaction’s end
  • Lamports may only be subtracted from accounts owned by the subtracting program
§data: Rc<RefCell<&'static mut [u8]>>

The data the account stores. Public information, can be read by anyone on the network. Also stores the starting length so can error if changed too far.

§Change Limitations

  • Data size may only be changed by the system program
  • Data size cannot be changed once set except by account wipe if no rent
  • Data can only be changed by the owning program
  • Data will be wiped if there is no rent
§original_data_len: &'static usize

The original data size. Can only see in it’s own call meaning the parent CPI size won’t be passed down.

§owner: &'static RefCell<&'static mut Pubkey>

The owning program of the account, defaults to the system program for new accounts

§Change Limitations

  • Owner can only be changed by the owning program
  • All data must be zeroed to be transferred
§executable: bool

Whether or not the account is executable

§rent_epoch: Epoch

The next epoch this account owes rent. Can be rent free by giving two years of rent.

Implementations§

Source§

impl CruiserAccountInfo

Source

pub unsafe fn deserialize( input: *mut u8, ) -> (&'static Pubkey, Vec<Self>, &'static [u8])

Deserializes the program input

§Safety

Must only be called on solana program input.

Source

pub unsafe fn to_solana_account_info<'a>(&self) -> SolanaAccountInfo<'a>

Turns this into a normal solana_program::account_info::AccountInfo for usage with standard functions.

§Safety

The resulting account info has owner as a shared reference that can be modified. Only use this when the resulting account info will never be used after another use of self or any values stemming from self.

Trait Implementations§

Source§

impl AccountArgument for CruiserAccountInfo

Source§

type AccountInfo = CruiserAccountInfo

The account info type this deals with
Source§

fn write_back(self, _program_id: &Pubkey) -> CruiserResult<()>

The final step in the instruction lifecycle, performing any cleanup operations or writes back.
Source§

fn add_keys( &self, add: impl FnMut(Pubkey) -> CruiserResult<()>, ) -> CruiserResult<()>

Passes all the account keys to a given function.
Source§

fn keys(&self) -> CruiserResult<Vec<Pubkey>>

Collects all the account keys into a Vec.
Source§

impl<'a> AccountInfoAccess<'a> for CruiserAccountInfo

Source§

type Lamports = Ref<'a, u64>

Source§

type LamportsMut = RefMut<'a, u64>

Source§

type Data = Ref<'a, [u8]>

Source§

type DataMut = RefMut<'a, [u8]>

Source§

type Owner = Ref<'a, Pubkey>

Source§

fn key(&'a self) -> &Pubkey

Gets the key of the account
Source§

fn is_signer(&'a self) -> bool

Returns true if this account is a signer
Source§

fn is_writable(&'a self) -> bool

Returns true if this account is writable
Source§

fn lamports(&'a self) -> Self::Lamports

Returns a shared ref to the lamports of this account
Source§

fn lamports_mut(&'a self) -> Self::LamportsMut

Returns a mutable ref to the lamports of this account
Source§

fn data(&'a self) -> Self::Data

Returns a shared ref to the data of this account
Source§

fn data_mut(&'a self) -> Self::DataMut

Returns a mutable ref to the data of this account
Source§

unsafe fn realloc_unsafe( &self, new_len: usize, zero_init: bool, ) -> CruiserResult

Reallocates the data of this account allowing for size change after initialization. Must be done by the owning program. Should use SafeRealloc whenever possible. Read more
Source§

fn owner(&'a self) -> Self::Owner

Returns a shared ref to the owner of this account
Source§

unsafe fn set_owner_unsafe(&self, new_owner: &Pubkey)

Unsafe access to changing the owner of this account. You should use SafeOwnerChangeAccess::owner_mut if possible. Read more
Source§

fn executable(&self) -> bool

This account’s data contains a loaded program (and is now read-only)
Source§

fn rent_epoch(&self) -> Epoch

The epoch at which this account will next owe rent
Source§

impl Clone for CruiserAccountInfo

Source§

fn clone(&self) -> CruiserAccountInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CruiserAccountInfo

Source§

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

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

impl FromAccounts<()> for CruiserAccountInfo

Source§

fn from_accounts( _program_id: &Pubkey, infos: &mut impl AccountInfoIterator<Item = Self::AccountInfo>, _arg: (), ) -> CruiserResult<Self>

Creates this argument from an AI iterator and data Arg. Read more
Source§

fn accounts_usage_hint(_arg: &()) -> (usize, Option<usize>)

A hint as to the number of accounts that this will use when FromAccounts::from_accounts is called. Returns (lower_bound, upper_bound) where lower_bound is the minimum and upper_bound is the maximum or None if there is no maximum. Read more
Source§

impl MultiIndexable<()> for CruiserAccountInfo

Source§

fn index_is_signer(&self, _indexer: ()) -> CruiserResult<bool>

Returns whether the account at index indexer is a signer.
Source§

fn index_is_writable(&self, _indexer: ()) -> CruiserResult<bool>

Returns whether the account at index indexer is writable.
Source§

fn index_is_owner(&self, owner: &Pubkey, _indexer: ()) -> CruiserResult<bool>

Returns whether the account at index indexer’s owner is owner.
Source§

impl MultiIndexable<AllAny> for CruiserAccountInfo

Source§

fn index_is_signer(&self, indexer: AllAny) -> CruiserResult<bool>

Returns whether the account at index indexer is a signer.
Source§

fn index_is_writable(&self, indexer: AllAny) -> CruiserResult<bool>

Returns whether the account at index indexer is writable.
Source§

fn index_is_owner(&self, owner: &Pubkey, indexer: AllAny) -> CruiserResult<bool>

Returns whether the account at index indexer’s owner is owner.
Source§

impl PartialEq for CruiserAccountInfo

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> SafeOwnerChangeAccess<'a> for CruiserAccountInfo

Source§

type OwnerMut = RefMut<'a, Pubkey>

Source§

fn owner_mut(&'a self) -> Self::OwnerMut

Returns a mutable ref to the owner of this account
Source§

impl<'a> SafeReallocAccess<'a> for CruiserAccountInfo

Source§

fn realloc(&self, new_len: usize, zero_init: bool) -> CruiserResult

Reallocates an account safely by checking data size. If this can be called in a cpi from the same program or earlier owning program of this account you should use SafeReallocAccess::realloc_cpi_safe.
Source§

fn realloc_cpi_safe(&self, new_len: usize, zero_init: bool) -> CruiserResult

Reallocates an account safely by checking data size, only allows for 1/4 the increase of MAX_PERMITTED_DATA_INCREASE. This limited growth means that a cpi call can never exceed MAX_PERMITTED_DATA_INCREASE.
Source§

impl SingleIndexable<()> for CruiserAccountInfo

Source§

fn index_info(&self, _indexer: ()) -> CruiserResult<&CruiserAccountInfo>

Gets the account info at index indexer
Source§

fn index_to_solana_account_meta( &self, indexer: I, ) -> CruiserResult<SolanaAccountMeta>
where Self::AccountInfo: AccountInfo,

Turns the account at index indexer to a SolanaAccountMeta
Source§

impl<'as_info: 'account, 'account> ToSolanaAccountInfoAccess<'as_info, 'account> for CruiserAccountInfo

Source§

unsafe fn to_solana_account_info(&'account self) -> SolanaAccountInfo<'as_info>

Turns this into a solana account info for interoperability and CPI. Read more
Source§

impl ValidateArgument<()> for CruiserAccountInfo

Source§

fn validate(&mut self, _program_id: &Pubkey, _arg: ()) -> CruiserResult<()>

Runs validation on this account with data Arg. Read more
Source§

impl Eq for CruiserAccountInfo

Source§

impl StructuralPartialEq for CruiserAccountInfo

Auto Trait Implementations§

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> Single for T
where T: SingleIndexable<()>,

Source§

fn info(&self) -> &<T as AccountArgument>::AccountInfo

Gets the account info for this argument.
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> ToSolanaAccountMeta for T

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

Source§

impl<T> AccountInfo for T
where T: for<'a> AccountInfoAccess<'a>,

Source§

impl<T> SafeOwnerChange for T
where T: for<'a> SafeOwnerChangeAccess<'a>,

Source§

impl<T> SafeRealloc for T
where T: for<'a> SafeReallocAccess<'a>,

Source§

impl<'as_info, T> ToSolanaAccountInfo<'as_info> for T
where T: for<'account> ToSolanaAccountInfoAccess<'as_info, 'account>,