pub struct BorrowedAccount { /* private fields */ }Expand description
Borrowed zero-copy account view into an aligned external buffer.
Implementations§
Source§impl BorrowedAccount
impl BorrowedAccount
Sourcepub unsafe fn span(ptr: NonNull<StorageUnit>) -> u32
pub unsafe fn span(ptr: NonNull<StorageUnit>) -> u32
Returns the total borrowed span in StorageUnits.
§Safety
ptr must point to a valid borrowed buffer created by
OwnedAccount::serialize.
Sourcepub unsafe fn pubkey(ptr: NonNull<StorageUnit>) -> Pubkey
pub unsafe fn pubkey(ptr: NonNull<StorageUnit>) -> Pubkey
Reads the account’s pubkey stored in the image prefix.
§Safety
ptr must point to a valid borrowed buffer created by
OwnedAccount::serialize.
Sourcepub unsafe fn init(buffer: NonNull<StorageUnit>) -> Self
pub unsafe fn init(buffer: NonNull<StorageUnit>) -> Self
Builds a borrowed account view from an aligned account buffer.
§Safety
buffer must be 8-byte aligned and point to a valid borrowed account
buffer whose first bytes are the account header, followed by two
image-sized payloads. The active image is selected from the header
sequence parity.
Sourcepub unsafe fn translate(&mut self)
pub unsafe fn translate(&mut self)
Copies the active image into the shadow image and switches to it.
§Safety
The borrowed image must still be the one selected by init.
Sourcepub fn commit(&self)
pub fn commit(&self)
Publishes the shadow image if it was prepared against the current sequence.
Sourcepub unsafe fn reset(&mut self)
pub unsafe fn reset(&mut self)
Repoints this view to the currently active image without copying data.
§Safety
The header must remain live, and self must be a view previously produced
by Self::init or Self::translate for that borrowed buffer.