Wasmex.Pipe (Wasmex v0.7.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

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

Link to this section Functions

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

Creates and returns a new Pipe.

@spec read(t()) :: binary()

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

Link to this function

set_len(pipe, len)

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

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

@spec 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)

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

Writes the given binary into the pipe.