pub struct AccountReader<'a> { /* private fields */ }Expand description
Header-aware read-only account reader.
Provides typed access to the header fields and a SliceCursor for the body.
Implementations§
Source§impl<'a> AccountReader<'a>
impl<'a> AccountReader<'a>
Sourcepub fn new(data: &'a [u8]) -> Result<Self, ProgramError>
pub fn new(data: &'a [u8]) -> Result<Self, ProgramError>
Create a reader, validating minimum header size.
Sourcepub fn new_checked(
data: &'a [u8],
disc: u8,
min_version: u8,
layout_id: &[u8; 8],
) -> Result<Self, ProgramError>
pub fn new_checked( data: &'a [u8], disc: u8, min_version: u8, layout_id: &[u8; 8], ) -> Result<Self, ProgramError>
Create a reader with full header validation.
Sourcepub fn header(&self) -> &AccountHeader
pub fn header(&self) -> &AccountHeader
The underlying header, zero-copy.
Sourcepub fn discriminator(&self) -> u8
pub fn discriminator(&self) -> u8
Discriminator byte.
Sourcepub fn body(&self) -> SliceCursor<'a>
pub fn body(&self) -> SliceCursor<'a>
Body data after the header as a cursor.
Sourcepub fn body_bytes(&self) -> &'a [u8]
pub fn body_bytes(&self) -> &'a [u8]
Raw body bytes after the header.
Sourcepub fn u64_at(&self, offset: usize) -> Result<u64, ProgramError>
pub fn u64_at(&self, offset: usize) -> Result<u64, ProgramError>
Read a u64 at a specific offset from the start of data.
Sourcepub fn address_at(&self, offset: usize) -> Result<&'a [u8; 32], ProgramError>
pub fn address_at(&self, offset: usize) -> Result<&'a [u8; 32], ProgramError>
Read a 32-byte address at a specific offset.
Sourcepub fn overlay_at<T: Pod + FixedLayout>(
&self,
offset: usize,
) -> Result<&'a T, ProgramError>
pub fn overlay_at<T: Pod + FixedLayout>( &self, offset: usize, ) -> Result<&'a T, ProgramError>
Overlay a Pod type at a specific offset.
Auto Trait Implementations§
impl<'a> Freeze for AccountReader<'a>
impl<'a> RefUnwindSafe for AccountReader<'a>
impl<'a> Send for AccountReader<'a>
impl<'a> Sync for AccountReader<'a>
impl<'a> Unpin for AccountReader<'a>
impl<'a> UnsafeUnpin for AccountReader<'a>
impl<'a> UnwindSafe for AccountReader<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more