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§
sourcefn account<Ret>(
&self,
index: usize,
callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret,
) -> Ret
fn account<Ret>( &self, index: usize, callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret, ) -> Ret
account at ‘index’
fn slot(&self, index: usize) -> Slot
sourcefn target_slot(&self) -> Slot
fn target_slot(&self) -> Slot
slot that all accounts are to be written to
Provided Methods§
sourcefn account_default_if_zero_lamport<Ret>(
&self,
index: usize,
callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret,
) -> Ret
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
sourcefn contains_multiple_slots(&self) -> bool
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])
impl<'a> StorableAccounts<'a> for (Slot, &'a [StakeReward])
allow StakeReward to be passed to StoreAccounts
directly without copies or vec construction