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
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])
impl<'a> StorableAccounts<'a> for (Slot, &'a [StakeReward])
allow StakeReward to be passed to StoreAccounts
directly without copies or vec construction