pub struct ConstantCostRules { /* private fields */ }
Expand description
A type that implements Rules
so that every instruction costs the same.
This is a simplification that is mostly useful for development and testing.
§Note
In a production environment it usually makes no sense to assign every instruction
the same cost. A proper implemention of Rules
should be prived that is probably
created by benchmarking.
Implementations§
Source§impl ConstantCostRules
impl ConstantCostRules
Sourcepub fn new(
instruction_cost: u32,
memory_grow_cost: u32,
call_per_local_cost: u32,
) -> ConstantCostRules
pub fn new( instruction_cost: u32, memory_grow_cost: u32, call_per_local_cost: u32, ) -> ConstantCostRules
Create a new ConstantCostRules
.
Uses instruction_cost
for every instruction and memory_grow_cost
to dynamically
meter the memory growth instruction.
Trait Implementations§
Source§impl Default for ConstantCostRules
impl Default for ConstantCostRules
Source§fn default() -> ConstantCostRules
fn default() -> ConstantCostRules
Uses instruction cost of 1
and disables memory growth instrumentation.
Source§impl Rules for ConstantCostRules
impl Rules for ConstantCostRules
Source§fn instruction_cost(&self, _: &Instruction) -> Option<u32>
fn instruction_cost(&self, _: &Instruction) -> Option<u32>
Returns the cost for the passed
instruction
. Read moreSource§fn memory_grow_cost(&self) -> MemoryGrowCost
fn memory_grow_cost(&self) -> MemoryGrowCost
Returns the costs for growing the memory using the
memory.grow
instruction. Read moreSource§fn call_per_local_cost(&self) -> u32
fn call_per_local_cost(&self) -> u32
A surcharge cost to calling a function that is added per local variable of the function.
Auto Trait Implementations§
impl Freeze for ConstantCostRules
impl RefUnwindSafe for ConstantCostRules
impl Send for ConstantCostRules
impl Sync for ConstantCostRules
impl Unpin for ConstantCostRules
impl UnwindSafe for ConstantCostRules
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