Wasm::Wasmtime::Module::Exports - Wasmtime module exports class
version 0.23
use Wasm::Wasmtime; my $module = Wasm::Wasmtime::Module->new( wat => q{ (module (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add) ) }); my $exports = $module->exports; # Wasm::Wasmtime::Module::Exports my $type1 = $exports->add; # this is the Wasm::Wasmtime::FuncType for add my $type2 = $exports->{add}; # this is also the Wasm::Wasmtime::FuncType for add my $exporttype = $exports->[0]; # this is the Wasm::Wasmtime::ExportType for add
WARNING: WebAssembly and Wasmtime are a moving target and the interface for these modules is under active development. Use with caution.
This class represents the exports from a module. It can be used in a number of different ways.
my $foo = $module->exports->foo;
Calling the name of an export as a method returns the Wasm::Wasmtime::ExternType for the export.
my $foo = $module->exports->{foo};
Using the Exports class as a hash reference allows you to get exports that might clash with common Perl methods like new
, can
, DESTROY
, etc. The Wasm::Wasmtime::ExternType will be returned.
my $foo = $module->exports->[0];
This will give you the list of exports in the order that they are defined in your WebAssembly. The object returned is a Wasm::Wasmtime::ExportType, which is essentially a name and a Wasm::Wasmtime::ExternType.
Graham Ollis <plicease@cpan.org>
This software is copyright (c) 2020-2022 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.