NAME

Wasm::Wasmtime::Instance::Exports - Wasmtime instance exports class

VERSION

version 0.23

SYNOPSIS

use Wasm::Wasmtime;

my $store = Wasm::Wasmtime::Store->new;
my $module = Wasm::Wasmtime::Module->new( $store->engine, wat => q{
  (module
   (func (export "add") (param i32 i32) (result i32)
     local.get 0
     local.get 1
     i32.add)
  )
});

my $instance = Wasm::Wasmtime::Instance->new($module, $store);

my $exports = $instance->exports;

print $exports->add->call(1,2),   "\n";  # 3
print $exports->{add}->call(1,2), "\n";  # 3
print $exports->[0]->call(1,2),   "\n";  # 3

DESCRIPTION

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 an instance. It can be used in a number of different ways.

autoload methods
my $foo = $instance->exports->foo;

Calling the name of an export as a method returns the Wasm::Wasmtime::ExternType for the export.

As a hash reference
my $foo = $instance->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.

An array reference
my $foo = $instance->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.

SEE ALSO

Wasm
Wasm::Wasmtime

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

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.