pub struct Budget(_);
Available on crate feature testutils only.
Expand description

Budget that tracks the resources consumed for the environment.

The budget consistents of two cost dimensions:

  • CPU instructions
  • Memory

Inputs feed into those cost dimensions.

Note that all cost dimensions – CPU instructions, memory – and the VM cost type inputs are likely to be underestimated when running Rust code compared to running the WASM equivalent.

Examples

use soroban_sdk::{Env, Symbol};

env.budget().reset();
// ...
println!("{}", env.budget());

Implementations§

Reset the budget.

Returns the CPU instruction cost.

Note that CPU instructions are likely to be underestimated when running Rust code compared to running the WASM equivalent.

Returns the memory cost.

Note that memory is likely to be underestimated when running Rust code compared to running the WASM equivalent.

Get inputs that have led to the cost.

Note that VM cost types are likely to be underestimated when running Rust code compared to running the WASM equivalent.

Print the budget costs and inputs to stdout.

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.