Struct budvm::Budgeted

source ·
pub struct Budgeted<Env> {
    pub env: Env,
    /* private fields */
}
Expand description

An Environment that allows executing an amount of instructions before pausing the virtual machine.

Fields§

§env: Env

The wrapped environment.

Implementations§

source§

impl Budgeted<()>

source

pub fn empty() -> Self

Returns a budgeted default environment.

source§

impl<Env> Budgeted<Env>

source

pub const fn new(initial_budget: usize, env: Env) -> Self

Returns a new instance with the provided initial budget.

source

pub const fn balance(&self) -> usize

Returns the current balance of the budget.

source

pub fn charge(&mut self) -> bool

Returns the current balance of the budget.

source

pub fn add_budget(&mut self, additional_budget: usize)

Adds an additional budget. This value will saturate usize instead of panicking or overflowing.

Trait Implementations§

source§

impl<Env: Debug> Debug for Budgeted<Env>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Env: Default> Default for Budgeted<Env>

source§

fn default() -> Budgeted<Env>

Returns the “default value” for a type. Read more
source§

impl<Env> Environment for Budgeted<Env>where Env: Environment,

§

type String = <Env as Environment>::String

The string type for this environment.
§

type Intrinsic = <Env as Environment>::Intrinsic

The intrinsics offered by this environment.
source§

fn step(&mut self) -> ExecutionBehavior

Called once before each instruction is executed. Read more
source§

fn intrinsic( &mut self, intrinsic: &Self::Intrinsic, args: PoppedValues<'_> ) -> Result<Value, FaultKind>

Evalutes the intrinsic operation with the provided arguments. Read more
source§

fn convert(&self, value: &Value, kind: &Symbol) -> Result<Value, FaultKind>

Converts value to a custom type supported by the runtime. Read more
source§

fn convert_string(&self, value: &Value) -> Result<Value, FaultKind>

Converts value to a Value containing an instance of Self::String. Read more

Auto Trait Implementations§

§

impl<Env> RefUnwindSafe for Budgeted<Env>where Env: RefUnwindSafe,

§

impl<Env> Send for Budgeted<Env>where Env: Send,

§

impl<Env> Sync for Budgeted<Env>where Env: Sync,

§

impl<Env> Unpin for Budgeted<Env>where Env: Unpin,

§

impl<Env> UnwindSafe for Budgeted<Env>where Env: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.