pub struct GasAllowanceCounter(/* private fields */);
Expand description
Gas allowance counter with some predefined maximum value.
Implementations§
Source§impl GasAllowanceCounter
impl GasAllowanceCounter
Sourcepub fn new(initial_amount: u64) -> Self
pub fn new(initial_amount: u64) -> Self
New limited gas allowance counter with initial value to spend.
Sourcepub fn charge<T: Into<u64>>(&mut self, amount: T) -> ChargeResult
pub fn charge<T: Into<u64>>(&mut self, amount: T) -> ChargeResult
Account for used gas allowance.
If there is no enough gas, then makes saturating charge and returns NotEnough
.
Else charges gas and returns Enough
.
Sourcepub fn charge_if_enough<T: Into<u64>>(&mut self, amount: T) -> ChargeResult
pub fn charge_if_enough<T: Into<u64>>(&mut self, amount: T) -> ChargeResult
Account for used gas allowance.
If there is no enough gas, then does nothing and returns ChargeResult::NotEnough
.
Else charges gas and returns ChargeResult::Enough
.
Trait Implementations§
Source§impl Clone for GasAllowanceCounter
impl Clone for GasAllowanceCounter
Source§fn clone(&self) -> GasAllowanceCounter
fn clone(&self) -> GasAllowanceCounter
Returns a copy 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 moreAuto Trait Implementations§
impl Freeze for GasAllowanceCounter
impl RefUnwindSafe for GasAllowanceCounter
impl Send for GasAllowanceCounter
impl Sync for GasAllowanceCounter
impl Unpin for GasAllowanceCounter
impl UnwindSafe for GasAllowanceCounter
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