NAME

Wasm::Wasmtime::WasiConfig - WASI Configuration

VERSION

version 0.24

SYNOPSIS

use Wasm::Wasmtime;

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

# inherit everything, and provide access to the
# host filesystem under /host (yikes!)
$config->inherit_argv
       ->inherit_env
       ->inherit_stdin
       ->inherit_stdout
       ->inherit_stderr
       ->preopen_dir("/", "/host");

# Apply the WASI configuration to the store (this consumes $config).
$store->set_wasi($config);

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 WebAssembly System Interface (WASI) configuration.

To apply a WASI configuration, pass it to $store->set_wasi($config) (which consumes it) and define the WASI imports on a linker with $linker->define_wasi.

CONSTRUCTOR

new

my $config = Wasm::Wasmtime::WasiConfig->new;

Creates a new WASI config object.

METHODS

set_argv

$config->set_argv(@argv);

inherit_argv

$config->inherit_argv;

set_env

$config->set_env(\%env);
$config->set_env(%env);

inherit_env

set_stdin_file

$config->set_stdin_file($path);

inherit_stdin

set_stdout_file

$config->set_stdout_file($path);

inherit_stdout

set_stderr_file

$config->set_stderr_file($path);

inherit_stderr

preopen_dir

$config->preopen_dir($host_path, $guest_path);
$config->preopen_dir($host_path, $guest_path, $fs_mutable);

Pre-open $host_path from the host, visible to the guest as $guest_path. $fs_mutable (default true) controls whether the guest may modify the filesystem under that path.

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.