pub struct Account<'info, T: LayoutContract> { /* private fields */ }Expand description
Account with a verified Hopper layout owned by the executing program.
Account<'info, T> expands to the same checks as
#[account] with layout = T: check_owned_by(program_id) +
load::<T>() (which verifies the header, discriminator, version,
and wire fingerprint). Field access is through get() / get_mut()
which return typed references into the borrowed account data.
Implementations§
Source§impl<'info, T: LayoutContract> Account<'info, T>
impl<'info, T: LayoutContract> Account<'info, T>
Sourcepub unsafe fn new_unchecked(view: &'info AccountView) -> Self
pub unsafe fn new_unchecked(view: &'info AccountView) -> Self
Wrap an already-validated AccountView. Unsafe because the
caller must have verified owner + layout header.
Sourcepub fn try_new(
view: &'info AccountView,
owner: &Address,
) -> Result<Self, ProgramError>
pub fn try_new( view: &'info AccountView, owner: &Address, ) -> Result<Self, ProgramError>
Wrap with owner + layout verification.
Sourcepub fn as_account(&self) -> &'info AccountView
pub fn as_account(&self) -> &'info AccountView
The underlying account view.
Sourcepub fn load(&self) -> Result<Ref<'_, T>, ProgramError>
pub fn load(&self) -> Result<Ref<'_, T>, ProgramError>
Borrow the typed layout for reading.
Sourcepub fn load_mut(&self) -> Result<RefMut<'_, T>, ProgramError>
pub fn load_mut(&self) -> Result<RefMut<'_, T>, ProgramError>
Borrow the typed layout for writing.
Trait Implementations§
Source§impl<'info, T: LayoutContract> Clone for Account<'info, T>
impl<'info, T: LayoutContract> Clone for Account<'info, T>
impl<'info, T: LayoutContract> Copy for Account<'info, T>
Auto Trait Implementations§
impl<'info, T> Freeze for Account<'info, T>
impl<'info, T> RefUnwindSafe for Account<'info, T>where
T: RefUnwindSafe,
impl<'info, T> Send for Account<'info, T>where
T: Send,
impl<'info, T> Sync for Account<'info, T>where
T: Sync,
impl<'info, T> Unpin for Account<'info, T>where
T: Unpin,
impl<'info, T> UnsafeUnpin for Account<'info, T>
impl<'info, T> UnwindSafe for Account<'info, T>where
T: UnwindSafe,
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