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

Object Safety§

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§