pub struct BalanceSnapshot { /* private fields */ }Expand description
Snapshot of a single account’s lamports for simple balance assertions.
Implementations§
Source§impl BalanceSnapshot
impl BalanceSnapshot
Sourcepub fn capture(account: &AccountView) -> Self
pub fn capture(account: &AccountView) -> Self
Capture a single account’s lamport balance.
Sourcepub fn verify_increased_by(
&self,
account: &AccountView,
min_increase: u64,
) -> ProgramResult
pub fn verify_increased_by( &self, account: &AccountView, min_increase: u64, ) -> ProgramResult
Verify the balance increased by at least min_increase.
Sourcepub fn verify_decreased_by_at_most(
&self,
account: &AccountView,
max_decrease: u64,
) -> ProgramResult
pub fn verify_decreased_by_at_most( &self, account: &AccountView, max_decrease: u64, ) -> ProgramResult
Verify the balance decreased by at most max_decrease.
Sourcepub fn verify_unchanged(&self, account: &AccountView) -> ProgramResult
pub fn verify_unchanged(&self, account: &AccountView) -> ProgramResult
Verify the balance is unchanged.
Sourcepub fn net_change(&self, account: &AccountView) -> i128
pub fn net_change(&self, account: &AccountView) -> i128
Compute the net change (positive = gained, negative = lost).
Returns the change as an i128 to avoid overflow.
Trait Implementations§
Source§impl Clone for BalanceSnapshot
impl Clone for BalanceSnapshot
Source§fn clone(&self) -> BalanceSnapshot
fn clone(&self) -> BalanceSnapshot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BalanceSnapshot
impl Debug for BalanceSnapshot
impl Copy for BalanceSnapshot
Auto Trait Implementations§
impl Freeze for BalanceSnapshot
impl RefUnwindSafe for BalanceSnapshot
impl Send for BalanceSnapshot
impl Sync for BalanceSnapshot
impl Unpin for BalanceSnapshot
impl UnsafeUnpin for BalanceSnapshot
impl UnwindSafe for BalanceSnapshot
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