logo

Function wasmer::wasm_c_api::engine::wasm_config_set_engine[][src]

#[no_mangle]
pub extern "C" fn wasm_config_set_engine(
    config: &mut wasm_config_t,
    engine: wasmer_engine_t
)
Expand description

Updates the configuration to specify a particular engine to use.

This is a Wasmer-specific function.

Example

int main() {
    // Create the configuration.
    wasm_config_t* config = wasm_config_new();

    // Use the Universal engine, if available.
    if (wasmer_is_engine_available(UNIVERSAL)) {
        wasm_config_set_engine(config, UNIVERSAL);
    }
    // Or maybe the Dylib engine?
    else if (wasmer_is_engine_available(DYLIB)) {
        wasm_config_set_engine(config, DYLIB);
    }
    // OK, let's do not specify any particular engine.

    // Create the engine.
    wasm_engine_t* engine = wasm_engine_new_with_config(config);

    // Check we have an engine!
    assert(engine);

    // Free everything.
    wasm_engine_delete(engine);

    return 0;
}