The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Wasm::Wasmer::WASI - Customized WASI configuration

SYNOPSIS

    my $wasi = $module->store()->create_wasi(
        name => 'name-of-program',  # empty string by default

        args => [ '--foo', 'bar' ],

        stdin => 'inherit',
        stdout => 'inherit',    # or 'capture'
        stderr => 'inherit',    # ^^ likewise

        env => [
            key1 => value1,
            key2 => value2,
            # ...
        ],

        preopen_dirs => [ '/path/to/dir' ],
        map_dirs => {
            '/alias/dir' => '/real/path',
            # ...
        },
    );

    my $instance = $module->create_wasi_instance($wasi);

DESCRIPTION

This module implements controls for Wasmer’s WASI implementation. As shown above, you use it to define the imports to give to a newly-created instance of a given module. From there you can run your program as you’d normally do.

This module is not directly instantiated; see Wasm::Wasmer::Store for how to create an instance.

METHODS

$store = OBJ->store()

Returns OBJ’s associated Wasm::Wasmer::Store instance.

$str = OBJ->read_stdout($LENGTH)

Reads and returns up to $LENGTH bytes from the internal STDOUT capture.

Only useful if new()’s stdout was capture.

$str = OBJ->read_stderr($LENGTH)

Like read_stdout() but for captured STDERR.