pub struct BuiltinContext { /* private fields */ }Expand description
A builtin actor execution context. Primarily used to track gas usage.
Implementations§
Source§impl BuiltinContext
impl BuiltinContext
Sourcepub fn new(counter_initial: u64, allowance_initial: u64) -> Self
pub fn new(counter_initial: u64, allowance_initial: u64) -> Self
Creates a new BuiltinContext with the specified initial gas and gas allowance.
Sourcepub fn try_charge_gas(&mut self, amount: u64) -> Result<(), BuiltinActorError>
pub fn try_charge_gas(&mut self, amount: u64) -> Result<(), BuiltinActorError>
Tries to charge the gas amount from the gas counters.
Sourcepub fn can_charge_gas(&self, amount: u64) -> Result<(), BuiltinActorError>
pub fn can_charge_gas(&self, amount: u64) -> Result<(), BuiltinActorError>
Checks if an amount of gas can be charged without actually modifying the inner counters.
Sourcepub fn to_gas_amount(&self) -> GasAmount
pub fn to_gas_amount(&self) -> GasAmount
Converts the current gas counter to a GasAmount.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BuiltinContext
impl RefUnwindSafe for BuiltinContext
impl Send for BuiltinContext
impl Sync for BuiltinContext
impl Unpin for BuiltinContext
impl UnwindSafe for BuiltinContext
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more