Wasm::Wasmtime::Module - Wasmtime module class
version 0.24
use Wasm::Wasmtime; my $module = Wasm::Wasmtime::Module->new( wat => '(module)' );
WARNING: WebAssembly and Wasmtime are a moving target and the interface for these modules is under active development. Use with caution.
This class represents a WebAssembly module.
my $module = Wasm::Wasmtime::Module->new( $engine, # Wasm::Wasmtime::Engine (optional) wat => $wat, # WebAssembly Text ); my $module = Wasm::Wasmtime::Module->new( $engine, # Wasm::Wasmtime::Engine (optional) wasm => $wasm, # WebAssembly binary ); my $module = Wasm::Wasmtime::Module->new( $engine, # Wasm::Wasmtime::Engine (optional) file => $path, # Filename containing WebAssembly binary (.wasm) or WebAssembly Text (.wat) );
Create a new WebAssembly module object. You must provide either WebAssembly Text (WAT), WebAssembly binary (Wasm), or a filename of a file that contains WebAssembly binary (Wasm) or text (Wat). If the optional Wasm::Wasmtime::Engine object is not provided one will be created for you. A Wasm::Wasmtime::Store may be passed instead of an engine, in which case its engine is used.
my $module = Wasm::Wasmtime::Module->deserialize( $engine, # Wasm::Wasmtime::Engine (optional) $serialized, # serialized module );
Build a module from serialized data. The serialized data can be gotten from the serialize method documented below.
my($ok, $message) = Wasm::Wasmtime::Module->validate( $engine, # Wasm::Wasmtime::Engine (optional) wat => $wat, # or wasm => $wasm, or file => $path );
Takes the same arguments as new, but validates the module without creating a module object.
my $exports = $module->exports;
Returns a Wasm::Wasmtime::Module::Exports object that can be used to query the module exports.
my $imports = $module->imports;
Returns a list of Wasm::Wasmtime::ImportType objects for the objects imported by the WebAssembly module.
my $serialized = $module->serialize;
This function serializes compiled module artifacts as blob data. This data can be reconstituted with the deserialize constructor method documented above.
my $engine = $module->engine;
Returns the Wasm::Wasmtime::Engine object used by this module.
my $string = $module->to_string;
Converts the module imports and exports into a string for diagnostics.
Graham Ollis <plicease@cpan.org>
This software is copyright (c) 2020-2026 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.