pub enum AccountsFile {
AppendVec(AppendVec),
}
Expand description
An enum for accessing an accounts file which can be implemented under different formats.
Variants§
Implementations§
source§impl AccountsFile
impl AccountsFile
sourcepub fn new_from_file(
path: impl AsRef<Path>,
current_len: usize
) -> Result<(Self, usize)>
pub fn new_from_file( path: impl AsRef<Path>, current_len: usize ) -> Result<(Self, usize)>
Create an AccountsFile instance from the specified path.
The second element of the returned tuple is the number of accounts in the accounts file.
sourcepub fn set_no_remove_on_drop(&mut self)
pub fn set_no_remove_on_drop(&mut self)
By default, all AccountsFile will remove its underlying file on drop. Calling this function to disable such behavior for this instance.
pub fn flush(&self) -> Result<()>
pub fn reset(&self)
pub fn remaining_bytes(&self) -> u64
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> u64
pub fn is_recyclable(&self) -> bool
pub fn file_name(slot: Slot, id: impl Display) -> String
sourcepub fn get_account(
&self,
index: usize
) -> Option<(StoredAccountMeta<'_>, usize)>
pub fn get_account( &self, index: usize ) -> Option<(StoredAccountMeta<'_>, usize)>
Return (account metadata, next_index) pair for the account at the
specified index
if any. Otherwise return None. Also return the
index of the next entry.
pub fn account_matches_owners( &self, offset: usize, owners: &[&Pubkey] ) -> Result<usize, MatchAccountOwnerError>
sourcepub fn account_iter(&self) -> AccountsFileIter<'_> ⓘ
pub fn account_iter(&self) -> AccountsFileIter<'_> ⓘ
Return iterator for account metadata
sourcepub fn accounts(&self, offset: usize) -> Vec<StoredAccountMeta<'_>>
pub fn accounts(&self, offset: usize) -> Vec<StoredAccountMeta<'_>>
Return a vector of account metadata for each account, starting from offset
.
sourcepub fn append_accounts<'a, 'b, T: ReadableAccount + Sync, U: StorableAccounts<'a, T>, V: Borrow<Hash>>(
&self,
accounts: &StorableAccountsWithHashesAndWriteVersions<'a, 'b, T, U, V>,
skip: usize
) -> Option<Vec<StoredAccountInfo>>
pub fn append_accounts<'a, 'b, T: ReadableAccount + Sync, U: StorableAccounts<'a, T>, V: Borrow<Hash>>( &self, accounts: &StorableAccountsWithHashesAndWriteVersions<'a, 'b, T, U, V>, skip: usize ) -> Option<Vec<StoredAccountInfo>>
Copy each account metadata, account and hash to the internal buffer.
If there is no room to write the first entry, None is returned.
Otherwise, returns the starting offset of each account metadata.
Plus, the final return value is the offset where the next entry would be appended.
So, return.len() is 1 + (number of accounts written)
After each account is appended, the internal current_len
is updated
and will be available to other threads.