Wasmex.Pipe (Wasmex v0.5.0)

A Pipe is a memory buffer that can be used in exchange for a WASM file. It can be used, for example, to capture stdout/stdin/stderr of a WASI program.

Link to this section Summary

Functions

Creates and returns a new Pipe.

Reads all available bytes from the Pipe and returns them as a binary.

Attempts to resize the pipe to the given number of bytes.

Returns the current size in bytes of the Pipe.

Writes the given binary into the pipe.

Link to this section Types

Specs

t() :: %Wasmex.Pipe{reference: reference(), resource: binary()}

Link to this section Functions

Specs

create() :: {:error, reason :: binary()} | {:ok, t()}

Creates and returns a new Pipe.

Specs

read(t()) :: binary()

Reads all available bytes from the Pipe and returns them as a binary.

Link to this function

set_len(pipe, len)

Specs

set_len(t(), integer()) :: :ok | :error

Attempts to resize the pipe to the given number of bytes.

Specs

size(t()) :: integer()

Returns the current size in bytes of the Pipe.

Link to this function

wrap_resource(resource)

Link to this function

write(pipe, binary)

Specs

write(t(), binary()) :: {:ok, integer()} | :error

Writes the given binary into the pipe.