NAME

Wasm::Wasmtime::Store - Wasmtime store class

VERSION

version 0.24

SYNOPSIS

use Wasm::Wasmtime;

my $store = Wasm::Wasmtime::Store->new;

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 storage used by the WebAssembly engine. In the modern Wasmtime C API almost every operation on a live WebAssembly object (function, memory, global, table, instance) is performed relative to a store, via its wasmtime_context_t. The "context" method exposes that pointer for internal use by the other Wasm::Wasmtime classes.

CONSTRUCTOR

new

my $store = Wasm::Wasmtime::Store->new;
my $store = Wasm::Wasmtime::Store->new(
  $engine,   # Wasm::Wasmtime::Engine
);

Creates a new storage instance. If the optional Wasm::Wasmtime::Engine object isn't provided, then a new one will be created.

METHODS

context

my $context = $store->context;

Returns the wasmtime_context_t pointer (an opaque) for this store. This is primarily for internal use by other Wasm::Wasmtime classes.

engine

my $engine = $store->engine;

Returns the Wasm::Wasmtime::Engine object for this storage object.

gc

$store->gc;

Garbage collects externrefs that are used within this store.

set_fuel

$store->set_fuel($fuel);

Sets the amount of fuel available for WebAssembly to consume while executing. Requires that the engine was configured with $config->consume_fuel(1).

get_fuel

my $fuel = $store->get_fuel;

Returns the amount of fuel remaining in this store.

set_wasi

$store->set_wasi($wasi_config);

Configures the WASI state for instances created within this store. Takes ownership of the Wasm::Wasmtime::WasiConfig object (it must not be used afterwards).

SEE ALSO

Wasm
Wasm::Wasmtime

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

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.