pub struct Module { /* private fields */ }
Expand description
A pseudo-random WebAssembly module.
Construct instances of this type (with default configuration) with the
Arbitrary
trait.
§Configuring Generated Modules
To configure the shape of generated module, create a
Config
and then call Module::new
with it.
Implementations§
Source§impl Module
impl Module
Sourcepub fn ensure_termination(&mut self, default_fuel: u32) -> Result<u32>
pub fn ensure_termination(&mut self, default_fuel: u32) -> Result<u32>
Ensure that all of this Wasm module’s functions will terminate when executed.
This adds a new mutable, exported global to the module to keep track of how much “fuel” is left. Fuel is decremented at the head of each loop and function. When fuel reaches zero, a trap is raised.
The index of the fuel global is returned, so that you may control how much fuel the module is given.
§Errors
Returns an error if any function body was generated with possibly-invalid bytes rather than being generated by wasm-smith. In such a situation this pass does not parse the input bytes and inject instructions, instead it returns an error.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Module
impl<'a> Arbitrary<'a> for Module
Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self
from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured
this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured
this type
needs to construct itself. Read more