🌻 📖 Wasm::Wasmtime::WasiConfig

NAME

Wasm::Wasmtime::WasiConfig - WASI Configuration

VERSION

version 0.23

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");
 
 my $wasi = Wasm::Wasmtime::WasiInstance->new(
   $store,
   "wasi_snapshot_preview1",
   $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. 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.

CONSTRUCTOR

new

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

Creates a new WASI config object.

METHODS

set_argv

 $config->set_argv(@argv);

Sets the program arguments.

inherit_argv

 $config->inherit_argv;

Configures WASI to use the host program's arguments.

set_env

 $config->set_env(\%env);

Sets the program environment variables.

inherit_env

 $config->inherit_env;

Configures WASI to use the host program's environment variables.

set_stdin_file

 $config->set_stdin_file($path);

Sets the program standard input to use the given file path.

inherit_stdin

 $config->inherit_stdin;

Configures WASI to use the host program's standard input.

set_stdout_file

 $config->set_stdout_file($path);

Sets the program standard output to use the given file path.

inherit_stdout

 $config->inherit_stdout;

Configures WASI to use the host program's standard output.

set_stderr_file

 $config->set_stderr_file($path);

Sets the program standard error to use the given file path.

inherit_stderr

 $config->inherit_stderr;

Configures WASI to use the host program's standard error.

preopen_dir

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

Pre-open the given directory from the host's $host_path to the guest's $guest_path.

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.