# `Kettlecorn.Runtime`
[🔗](https://github.com/mjrusso/kettlecorn/blob/v0.1.0/host/lib/kettlecorn/runtime.ex#L1)

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.

# `t`

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

# `cli`

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

The bundled script CLI for this runtime.

# `dir`

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

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

# `executable`

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

The bundled native launcher for this runtime.

# `find`

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

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

# `installed_dir`

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

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

# `load`

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

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

# `load!`

```elixir
@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`

```elixir
@spec protocol_version() :: pos_integer()
```

The protocol version required by the library.

# `version`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
