pub fn new_from_bytes<'a>(env: RustlerEnv<'a>, args: &[Term<'a>]) -> Result<Term<'a>, Error> {
    let binary: Binary = args[0].decode()?;
    let imports: MapIterator = args[1].decode()?;
    let bytes = binary.as_slice();

    let mut environment = Environment::new();
    let import_object = environment.import_object(imports)?;
    let store = Store::default();
    let module = match Module::new(&store, &bytes) {
        Ok(module) => module,
        Err(e) => {
            return Ok((atoms::error(), format!("Could not compule module: {:?}", e)).encode(env))
        }
    };
    let instance = match Instance::new(&module, &import_object) {
        Ok(instance) => instance,
        Err(e) => return Ok((atoms::error(), format!("Cannot Instantiate: {:?}", e)).encode(env)),
    };
    let memory = memory_from_instance(&instance)?.clone();
    environment.memory.initialize(memory);

    let resource = ResourceArc::new(InstanceResource {
        instance: Mutex::new(instance),
    });
    Ok((atoms::ok(), resource).encode(env))
}
// creates a new instance from the given WASM bytes
// expects the following elixir params
//
// * bytes (binary): the bytes of the WASM module
// * imports (map): a map defining eventual instance imports, may be empty if there are none.
//   structure: %{namespace_name: %{import_name: {TODO: signature}}}
creates a new instance from the given WASM bytes
expects the following elixir params

bytes (binary): the bytes of the WASM module
imports (map): a map defining eventual instance imports, may be empty if there are none.
creates a new instance from the given WASM bytes expects the following elixir params bytes ( binary ) : the bytes of the WASM module imports ( map ) : a map defining eventual instance imports may be empty if there are none .
pub fn new_from_bytes<'a>(env: RustlerEnv<'a>, args: &[Term<'a>]) -> Result<Term<'a>, Error> {
    let binary: Binary = args[0].decode()?;
    let imports: MapIterator = args[1].decode()?;
    let bytes = binary.as_slice();
    let mut environment = Environment::new();
    let import_object = environment.import_object(imports)?;
    let store = Store::default();
    let module = match Module::new(&store, &bytes) {
        Ok(module) => module,
        Err(e) => {
            return Ok((atoms::error(), format!("Could not compule module: {:?}", e)).encode(env))
        }
    };
    let instance = match Instance::new(&module, &import_object) {
        Ok(instance) => instance,
        Err(e) => return Ok((atoms::error(), format!("Cannot Instantiate: {:?}", e)).encode(env)),
    };
    let memory = memory_from_instance(&instance)?.clone();
    environment.memory.initialize(memory);
    let resource = ResourceArc::new(InstanceResource {
        instance: Mutex::new(instance),
    });
    Ok((atoms::ok(), resource).encode(env))
}
pub fn new_from_bytes < ' a > ( env : RustlerEnv < ' a > , args : & [ Term < ' a > ] ) -> Result < Term < ' a > , Error > { let binary : Binary = args [ 0 ] . decode ( ) ? ; let imports : MapIterator = args [ 1 ] . decode ( ) ? ; let bytes = binary . as_slice ( ) ; let mut environment = Environment :: new ( ) ; let import_object = environment . import_object ( imports ) ? ; let store = Store :: default ( ) ; let module = match Module :: new ( & store , & bytes ) { Ok ( module ) => module , Err ( e ) => { return Ok ( ( atoms :: error ( ) , format ! ( " " e ) ) . encode ( env ) ) } } ; let instance = match Instance :: new ( & module , & import_object ) { Ok ( instance ) => instance , Err ( e ) => return Ok ( ( atoms :: error ( ) , format ! ( " " e ) ) . encode ( env ) ) , } ; let memory = memory_from_instance ( & instance ) ? . clone ( ) ; environment . memory . initialize ( memory ) ; let resource = ResourceArc :: new ( InstanceResource { instance : Mutex :: new ( instance ) , } ) ; Ok ( ( atoms :: ok ( ) , resource ) . encode ( env ) ) }
creates a new instance from the given WASM bytes
expects the following elixir params
creates a new instance from the given WASM bytes expects the following elixir params
env
RustlerEnv<'a>
args
&[Term<'a>]
env
RustlerEnv<'a>
args
&[Term<'a>]