solana_accounts_db::storable_accounts

Trait StorableAccounts

Source
pub trait StorableAccounts<'a>: Sync {
    // Required methods
    fn account<Ret>(
        &self,
        index: usize,
        callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret,
    ) -> Ret;
    fn slot(&self, index: usize) -> Slot;
    fn target_slot(&self) -> Slot;
    fn len(&self) -> usize;

    // Provided methods
    fn account_default_if_zero_lamport<Ret>(
        &self,
        index: usize,
        callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret,
    ) -> Ret { ... }
    fn is_empty(&self) -> bool { ... }
    fn contains_multiple_slots(&self) -> bool { ... }
}
Expand description

abstract access to pubkey, account, slot, target_slot of either: a. (slot, &[&Pubkey, &ReadableAccount]) b. (slot, &[&Pubkey, &ReadableAccount, Slot]) (we will use this later) This trait avoids having to allocate redundant data when there is a duplicated slot parameter. All legacy callers do not have a unique slot per account to store.

Required Methods§

Source

fn account<Ret>( &self, index: usize, callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret, ) -> Ret

account at ‘index’

Source

fn slot(&self, index: usize) -> Slot

Source

fn target_slot(&self) -> Slot

slot that all accounts are to be written to

Source

fn len(&self) -> usize

§accounts to write

Provided Methods§

Source

fn account_default_if_zero_lamport<Ret>( &self, index: usize, callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret, ) -> Ret

None if account is zero lamports

Source

fn is_empty(&self) -> bool

true if no accounts to write

Source

fn contains_multiple_slots(&self) -> bool

are there accounts from multiple slots only used for an assert

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a> StorableAccounts<'a> for (Slot, &'a [StakeReward])

allow StakeReward to be passed to StoreAccounts directly without copies or vec construction

Source§

fn account<Ret>( &self, index: usize, callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret, ) -> Ret

Source§

fn slot(&self, _index: usize) -> Slot

Source§

fn target_slot(&self) -> Slot

Source§

fn len(&self) -> usize

Source§

impl<'a: 'b, 'b> StorableAccounts<'a> for (Slot, &'b [(&'a Pubkey, &'a AccountSharedData)])

Source§

fn account<Ret>( &self, index: usize, callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret, ) -> Ret

Source§

fn slot(&self, _index: usize) -> Slot

Source§

fn target_slot(&self) -> Slot

Source§

fn len(&self) -> usize

Implementors§