pub fn append_accounts(
        &self,
        accounts: &[(StoredMeta, Option<&impl ReadableAccount>)],
        hashes: &[impl Borrow<Hash>],
    ) -> Vec<usize> {
        let _lock = self.append_lock.lock().unwrap();
        let mut offset = self.len();
        let mut rv = Vec::with_capacity(accounts.len());
        for ((stored_meta, account), hash) in accounts.iter().zip(hashes) {
            let meta_ptr = stored_meta as *const StoredMeta;
            let account_meta = AccountMeta::from(*account);
            let account_meta_ptr = &account_meta as *const AccountMeta;
            let data_len = stored_meta.data_len as usize;
            let data_ptr = account
                .map(|account| account.data())
                .unwrap_or_default()
                .as_ptr();
            let hash_ptr = hash.borrow().as_ref().as_ptr();
            let ptrs = [
                (meta_ptr as *const u8, mem::size_of::<StoredMeta>()),
                (account_meta_ptr as *const u8, mem::size_of::<AccountMeta>()),
                (hash_ptr as *const u8, mem::size_of::<Hash>()),
                (data_ptr, data_len),
            ];
            if let Some(res) = self.append_ptrs_locked(&mut offset, &ptrs) {
                rv.push(res)
            } else {
                break;
            }
        }

        // The last entry in this offset needs to be the u64 aligned offset, because that's
        // where the *next* entry will begin to be stored.
        rv.push(u64_align!(offset));

        rv
    }
/// Copy each account metadata, account and hash to the internal buffer.
/// Return the starting offset of each account metadata.
/// After each account is appended, the internal `current_len` is updated
/// and will be available to other threads.
Copy each account metadata, account and hash to the internal buffer.
Return the starting offset of each account metadata.
After each account is appended, the internal `current_len` is updated
and will be available to other threads.
Copy each account metadata account and hash to the internal buffer . Return the starting offset of each account metadata . After each account is appended the internal ` current_len ` is updated and will be available to other threads .
pub fn append_accounts(
        &self,
        accounts: &[(StoredMeta, Option<&impl ReadableAccount>)],
        hashes: &[impl Borrow<Hash>],
    ) -> Vec<usize> {
        let _lock = self.append_lock.lock().unwrap();
        let mut offset = self.len();
        let mut rv = Vec::with_capacity(accounts.len());
        for ((stored_meta, account), hash) in accounts.iter().zip(hashes) {
            let meta_ptr = stored_meta as *const StoredMeta;
            let account_meta = AccountMeta::from(*account);
            let account_meta_ptr = &account_meta as *const AccountMeta;
            let data_len = stored_meta.data_len as usize;
            let data_ptr = account
                .map(|account| account.data())
                .unwrap_or_default()
                .as_ptr();
            let hash_ptr = hash.borrow().as_ref().as_ptr();
            let ptrs = [
                (meta_ptr as *const u8, mem::size_of::<StoredMeta>()),
                (account_meta_ptr as *const u8, mem::size_of::<AccountMeta>()),
                (hash_ptr as *const u8, mem::size_of::<Hash>()),
                (data_ptr, data_len),
            ];
            if let Some(res) = self.append_ptrs_locked(&mut offset, &ptrs) {
                rv.push(res)
            } else {
                break;
            }
        }
        // The last entry in this offset needs to be the u64 aligned offset, because that's
        // where the *next* entry will begin to be stored.
        rv.push(u64_align!(offset));
        rv
    }
pub fn append_accounts ( & self , accounts : & [ ( StoredMeta , Option < & impl ReadableAccount > ) ] , hashes : & [ impl Borrow < Hash > ] , ) -> Vec < usize > { let _lock = self . append_lock . lock ( ) . unwrap ( ) ; let mut offset = self . len ( ) ; let mut rv = Vec :: with_capacity ( accounts . len ( ) ) ; for ( ( stored_meta , account ) , hash ) in accounts . iter ( ) . zip ( hashes ) { let meta_ptr = stored_meta as * const StoredMeta ; let account_meta = AccountMeta :: from ( * account ) ; let account_meta_ptr = & account_meta as * const AccountMeta ; let data_len = stored_meta . data_len as usize ; let data_ptr = account . map ( | account | account . data ( ) ) . unwrap_or_default ( ) . as_ptr ( ) ; let hash_ptr = hash . borrow ( ) . as_ref ( ) . as_ptr ( ) ; let ptrs = [ ( meta_ptr as * const u8 , mem :: size_of :: < StoredMeta > ( ) ) , ( account_meta_ptr as * const u8 , mem :: size_of :: < AccountMeta > ( ) ) , ( hash_ptr as * const u8 , mem :: size_of :: < Hash > ( ) ) , ( data_ptr , data_len ) , ] ; if let Some ( res ) = self . append_ptrs_locked ( & mut offset , & ptrs ) { rv . push ( res ) } else { break ; } } // The last entry in this offset needs to be the u64 aligned offset, because that's // where the *next* entry will begin to be stored. rv . push ( u64_align ! ( offset ) ) ; rv }
Copy each account metadata, account and hash to the internal buffer.
Copy each account metadata account and hash to the internal buffer .
&self
accounts
&[(StoredMeta, Option<&impl ReadableAccount>)]
hashes
&[impl Borrow<Hash>]