Kettlecorn.Runtime (kettlecorn v0.1.0)

Copy Markdown View Source

Finds a platform runtime containing the native launcher, WebAssembly emulators and guest file system.

load!/1 checks the host platform and protocol version, then loads the manifest and launch/ files. Install the matching runtime with mix kettlecorn.install; Python and the Wasmtime CLI are not required.

dir/1 checks the :runtime option, $KETTLECORN_RUNTIME, config :kettlecorn, :runtime, then installed_dir/0. With Nix, nix build .#runtime builds the runtime.

The manifest records kettlecorn, protocol, platform, otp, elixir, component imports, and tested_with.wasmtime. The bundled launcher embeds that Wasmtime version. launch/ defines the guest's arguments and environment.

Summary

Functions

The bundled script CLI for this runtime.

The runtime directory to use (see the module docs), or nil when there is none.

The bundled native launcher for this runtime.

Finds and loads a runtime using the discovery order of dir/1.

Where Kettlecorn.Install.runtime/1 puts this version's runtime, under the user cache directory.

Like load!/1, but returns {:ok, runtime} or {:error, message}.

Loads one generation of the runtime in dir, resolving its publication link. Requires its manifest, executable launcher and CLI, launch/ files, emulators and root/. Checks the host platform and the library's protocol version. Both executables are required even when using only the host API. Raises if the runtime is incomplete or incompatible.

The protocol version required by the library.

The library's version, which is the version of the runtime it installs.

Types

t()

@type t() :: %Kettlecorn.Runtime{
  dir: Path.t(),
  manifest: Kettlecorn.Runtime.Manifest.t()
}

Functions

cli(runtime)

@spec cli(t()) :: Path.t()

The bundled script CLI for this runtime.

dir(opts \\ [])

@spec dir(keyword()) :: Path.t() | nil

The runtime directory to use (see the module docs), or nil when there is none.

executable(runtime)

@spec executable(t()) :: Path.t()

The bundled native launcher for this runtime.

find(opts)

@spec find(keyword()) :: {:ok, t()} | {:error, String.t()}

Finds and loads a runtime using the discovery order of dir/1.

installed_dir()

@spec installed_dir() :: Path.t()

Where Kettlecorn.Install.runtime/1 puts this version's runtime, under the user cache directory.

load(dir)

@spec load(Path.t()) :: {:ok, t()} | {:error, String.t()}

Like load!/1, but returns {:ok, runtime} or {:error, message}.

load!(dir)

@spec load!(Path.t()) :: t()

Loads one generation of the runtime in dir, resolving its publication link. Requires its manifest, executable launcher and CLI, launch/ files, emulators and root/. Checks the host platform and the library's protocol version. Both executables are required even when using only the host API. Raises if the runtime is incomplete or incompatible.

protocol_version()

@spec protocol_version() :: pos_integer()

The protocol version required by the library.

version()

@spec version() :: String.t()

The library's version, which is the version of the runtime it installs.