Wasm::Wasmtime::WasiConfig - WASI Configuration
version 0.11
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"); my $wasi = Wasm::Wasmtime::WasiInstance->new( $store, "wasi_snapshot_preview1", $config, );
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. For WebAssembly WASI is the equivalent to the part of libc that interfaces with the system. As such it allows you to configure if and how the WebAssembly program has access to program arguments, environment, standard streams and file system directories.
my $config = Wasm::Wasmtime::WasiConfig->new;
Creates a new WASI config object.
$config->set_argv(@argv);
Sets the program arguments.
$config->inherit_argv;
Configures WASI to use the host program's arguments.
$config->set_env(\%env);
Sets the program environment variables.
$config->inherit_env;
Configures WASI to use the host program's environment variables.
$config->set_stdin_file($path);
Sets the program standard input to use the given file path.
$config->inherit_stdin;
Configures WASI to use the host program's standard input.
$config->set_stdout_file($path);
Sets the program standard output to use the given file path.
$config->inherit_stdout;
Configures WASI to use the host program's standard output.
$config->set_stderr_file($path);
Sets the program standard error to use the given file path.
$config->inherit_stderr;
Configures WASI to use the host program's standard error.
$config->preopen_dir($host_path, $guest_path);
Pre-open the given directory from the host's $host_path to the guest's $guest_path.
$host_path
$guest_path
Graham Ollis <plicease@cpan.org>
This software is copyright (c) 2020 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.
To install Wasm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Wasm
CPAN shell
perl -MCPAN -e shell install Wasm
For more information on module installation, please visit the detailed CPAN module installation guide.