pub struct VerifiedAccountMut<'a, T>where
T: Pod + FixedLayout,{ /* private fields */ }Expand description
Mutable verified account – proof that validation passed, with write access.
Implementations§
Source§impl<'a, T> VerifiedAccountMut<'a, T>where
T: Pod + FixedLayout,
impl<'a, T> VerifiedAccountMut<'a, T>where
T: Pod + FixedLayout,
Sourcepub fn new(
data: &'a mut [u8],
) -> Result<VerifiedAccountMut<'a, T>, ProgramError>
pub fn new( data: &'a mut [u8], ) -> Result<VerifiedAccountMut<'a, T>, ProgramError>
Construct from pre-validated mutable data.
Sourcepub fn from_ref_mut(
data: RefMut<'a, [u8]>,
) -> Result<VerifiedAccountMut<'a, T>, ProgramError>
pub fn from_ref_mut( data: RefMut<'a, [u8]>, ) -> Result<VerifiedAccountMut<'a, T>, ProgramError>
Construct from a Hopper mutable borrow guard.
Sourcepub fn get(&self) -> &T
pub fn get(&self) -> &T
Get an immutable reference to the overlay.
The returned reference is bounded by &self; it cannot outlive this
VerifiedAccountMut, which owns the mutable borrow guard or validated
raw mutable slice.
Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Get a mutable reference to the overlay.
The returned reference is bounded by &mut self, so there can be only
one mutable overlay at a time and it cannot outlive the wrapper that
owns the underlying account borrow.
Sourcepub fn with_mut<U, F>(&mut self, f: F) -> U
pub fn with_mut<U, F>(&mut self, f: F) -> U
Run a closure with the verified mutable whole-layout overlay.
Sourcepub fn map_mut<U, F>(&mut self, f: F) -> U
pub fn map_mut<U, F>(&mut self, f: F) -> U
Project a field for mutation.
let mut vault = Vault::load_mut(account, program_id)?;
vault.map_mut(|v| {
v.balance = WireU64::new(100);
});Sourcepub fn overlay_at<U>(&self, offset: usize) -> Result<&U, ProgramError>where
U: Pod + FixedLayout,
pub fn overlay_at<U>(&self, offset: usize) -> Result<&U, ProgramError>where
U: Pod + FixedLayout,
Overlay a second Pod type at a given offset (immutable).
Sourcepub fn overlay_at_mut<U>(
&mut self,
offset: usize,
) -> Result<&mut U, ProgramError>where
U: Pod + FixedLayout,
pub fn overlay_at_mut<U>(
&mut self,
offset: usize,
) -> Result<&mut U, ProgramError>where
U: Pod + FixedLayout,
Overlay a second Pod type at a given offset (mutable).