pub fn instantiate(wasm: &[u8], strategy: Strategy) {
    if wasmparser::validate(wasm, None).is_err() {
        return;
    }

    let mut config = Config::new();
    config
        .strategy(strategy)
        .expect("failed to enable lightbeam");
    let engine = Engine::new(&config);
    let store = Store::new(&engine);

    let module = Module::new(&store, wasm).expect("Failed to compile a valid Wasm module!");

    let imports = match dummy_imports(&store, module.imports()) {
        Ok(imps) => imps,
        Err(_) => {
            // There are some value types that we can't synthesize a
            // dummy value for (e.g. anyrefs) and for modules that
            // import things of these types we skip instantiation.
            return;
        }
    };

    // Don't unwrap this: there can be instantiation-/link-time errors that
    // aren't caught during validation or compilation. For example, an imported
    // table might not have room for an element segment that we want to
    // initialize into it.
    let _result = Instance::new(&module, &imports);
}
/// Instantiate the Wasm buffer, and implicitly fail if we have an unexpected
/// panic or segfault or anything else that can be detected "passively".
///
/// Performs initial validation, and returns early if the Wasm is invalid.
///
/// You can control which compiler is used via passing a `Strategy`.
Instantiate the Wasm buffer, and implicitly fail if we have an unexpected
panic or segfault or anything else that can be detected "passively".

Performs initial validation, and returns early if the Wasm is invalid.

You can control which compiler is used via passing a `Strategy`.
Instantiate the Wasm buffer and implicitly fail if we have an unexpected panic or segfault or anything else that can be detected " passively " . Performs initial validation and returns early if the Wasm is invalid . You can control which compiler is used via passing a ` Strategy ` .
pub fn instantiate(wasm: &[u8], strategy: Strategy) {
    if wasmparser::validate(wasm, None).is_err() {
        return;
    }
    let mut config = Config::new();
    config
        .strategy(strategy)
        .expect("failed to enable lightbeam");
    let engine = Engine::new(&config);
    let store = Store::new(&engine);
    let module = Module::new(&store, wasm).expect("Failed to compile a valid Wasm module!");
    let imports = match dummy_imports(&store, module.imports()) {
        Ok(imps) => imps,
        Err(_) => {
            // There are some value types that we can't synthesize a
            // dummy value for (e.g. anyrefs) and for modules that
            // import things of these types we skip instantiation.
            return;
        }
    };
    // Don't unwrap this: there can be instantiation-/link-time errors that
    // aren't caught during validation or compilation. For example, an imported
    // table might not have room for an element segment that we want to
    // initialize into it.
    let _result = Instance::new(&module, &imports);
}
pub fn instantiate ( wasm : & [ u8 ] , strategy : Strategy ) { if wasmparser :: validate ( wasm , None ) . is_err ( ) { return ; } let mut config = Config :: new ( ) ; config . strategy ( strategy ) . expect ( " " ) ; let engine = Engine :: new ( & config ) ; let store = Store :: new ( & engine ) ; let module = Module :: new ( & store , wasm ) . expect ( " " ) ; let imports = match dummy_imports ( & store , module . imports ( ) ) { Ok ( imps ) => imps , Err ( _ ) => { // There are some value types that we can't synthesize a // dummy value for (e.g. anyrefs) and for modules that // import things of these types we skip instantiation. return ; } } ; // Don't unwrap this: there can be instantiation-/link-time errors that // aren't caught during validation or compilation. For example, an imported // table might not have room for an element segment that we want to // initialize into it. let _result = Instance :: new ( & module , & imports ) ; }
Instantiate the Wasm buffer, and implicitly fail if we have an unexpected
panic or segfault or anything else that can be detected "passively".
Instantiate the Wasm buffer and implicitly fail if we have an unexpected panic or segfault or anything else that can be detected " passively " .
wasm
&[u8]
strategy
Strategy
wasm
&[u8]
strategy
Strategy