pub struct StateSnapshot<const SIZE: usize> { /* private fields */ }Expand description
A stack-allocated snapshot of account data.
SIZE is the maximum number of bytes captured.
Implementations§
Source§impl<const SIZE: usize> StateSnapshot<SIZE>
impl<const SIZE: usize> StateSnapshot<SIZE>
Sourcepub fn capture(data: &[u8]) -> Self
pub fn capture(data: &[u8]) -> Self
Capture a snapshot of account data.
If the data is longer than SIZE, only the first SIZE bytes are captured
and was_truncated() returns true.
Sourcepub fn was_truncated(&self) -> bool
pub fn was_truncated(&self) -> bool
Whether the source data was larger than the snapshot buffer.
Sourcepub fn diff<'a>(&'a self, current: &'a [u8]) -> StateDiff<'a>
pub fn diff<'a>(&'a self, current: &'a [u8]) -> StateDiff<'a>
Compute a diff against current data.
Returns a StateDiff describing all changed regions.
Sourcepub fn has_changes(&self, current: &[u8]) -> bool
pub fn has_changes(&self, current: &[u8]) -> bool
Check if any bytes changed compared to current data.
Sourcepub fn range_changed(&self, current: &[u8], offset: usize, len: usize) -> bool
pub fn range_changed(&self, current: &[u8], offset: usize, len: usize) -> bool
Check if a specific byte range changed.
Sourcepub fn restore_into(&self, target: &mut [u8]) -> Result<(), ProgramError>
pub fn restore_into(&self, target: &mut [u8]) -> Result<(), ProgramError>
Restore the snapshot data back into a mutable slice.
Useful for rollback scenarios.
Auto Trait Implementations§
impl<const SIZE: usize> Freeze for StateSnapshot<SIZE>
impl<const SIZE: usize> RefUnwindSafe for StateSnapshot<SIZE>
impl<const SIZE: usize> Send for StateSnapshot<SIZE>
impl<const SIZE: usize> Sync for StateSnapshot<SIZE>
impl<const SIZE: usize> Unpin for StateSnapshot<SIZE>
impl<const SIZE: usize> UnsafeUnpin for StateSnapshot<SIZE>
impl<const SIZE: usize> UnwindSafe for StateSnapshot<SIZE>
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