referrerpolicy=no-referrer-when-downgrade

UnsafeConstructorDestructor

Trait UnsafeConstructorDestructor 

Source
pub trait UnsafeConstructorDestructor<Balance> {
    // Required methods
    fn unsafe_clone(&self) -> Box<dyn ImbalanceAccounting<Balance>>;
    fn forget_imbalance(&mut self) -> Balance;
}
Expand description

Unsafe imbalance cloning constructor and forgetful destructor.

This trait provides low-level operations that can violate imbalance invariants if misused. These methods are separated into their own trait to make it explicit when unsafe operations are being performed.

Required Methods§

Source

fn unsafe_clone(&self) -> Box<dyn ImbalanceAccounting<Balance>>

Duplicates/clones the imbalance type, effectively leading to double accounting of the imbalance.

Warning: Use with care!!! one of the duplicates should call self.forget_amount() for the double-tracking to be removed.

Source

fn forget_imbalance(&mut self) -> Balance

Forgets about the inner imbalance. Drops the inner imbalance without actually resolving it. Usually implemented by simply setting the imbalance amount to zero.

Note this is not equivalent mem::forget() as the destructor is still called, and memory is freed, but imbalance amount to resolve is zero/noop.

Returns the amount “forgotten”.

Implementors§

Source§

impl<A: AssetId + 'static, B: Balance + 'static, OnDrop: HandleImbalanceDrop<A, B> + 'static, OppositeOnDrop: HandleImbalanceDrop<A, B> + 'static> UnsafeConstructorDestructor<u128> for frame_support::traits::tokens::fungibles::Imbalance<A, B, OnDrop, OppositeOnDrop>

Source§

impl<B: Balance + 'static, OnDrop: HandleImbalanceDrop<B> + 'static, OppositeOnDrop: HandleImbalanceDrop<B> + 'static> UnsafeConstructorDestructor<u128> for frame_support::traits::tokens::fungible::Imbalance<B, OnDrop, OppositeOnDrop>