pub struct VerifiedAccountMut<'a, T: Pod + FixedLayout> { /* private fields */ }Expand description
Mutable verified account – proof that validation passed, with write access.
Implementations§
Source§impl<'a, T: Pod + FixedLayout> VerifiedAccountMut<'a, T>
impl<'a, T: Pod + FixedLayout> VerifiedAccountMut<'a, T>
Sourcepub fn new(data: &'a mut [u8]) -> Result<Self, ProgramError>
pub fn new(data: &'a mut [u8]) -> Result<Self, ProgramError>
Construct from pre-validated mutable data.
Sourcepub fn from_ref_mut(data: RefMut<'a, [u8]>) -> Result<Self, ProgramError>
pub fn from_ref_mut(data: RefMut<'a, [u8]>) -> Result<Self, 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: Pod + FixedLayout>(
&self,
offset: usize,
) -> Result<&U, ProgramError>
pub fn overlay_at<U: Pod + FixedLayout>( &self, offset: usize, ) -> Result<&U, ProgramError>
Overlay a second Pod type at a given offset (immutable).
Sourcepub fn overlay_at_mut<U: Pod + FixedLayout>(
&mut self,
offset: usize,
) -> Result<&mut U, ProgramError>
pub fn overlay_at_mut<U: Pod + FixedLayout>( &mut self, offset: usize, ) -> Result<&mut U, ProgramError>
Overlay a second Pod type at a given offset (mutable).