# `Alternera.PluginWasmFramework.Runtime.Port.Binary`
[🔗](https://github.com/10e-ab/alternera-wasm/blob/v0.9.1/alternera_plugin_wasm_framework/lib/alternera/plugin_wasm_framework/runtime/port/binary.ex#L1)

The host program of `Runtime.Port`, `alternera_wasm_host`, built from
the package's `native/alternera_wasm_host/` crate: where it is, what
it is started with, and whether it can run here.

The binary is looked for, in order, at

  1. the `ALTERNERA_WASM_HOST_PATH` environment variable, a binary
     someone built or put in place;
  2. the framework's `:host_path` application env;
  3. `priv/native/<target>/alternera_wasm_host` in the package, where
     `mix alternera.wasm_host` puts it (`Mix.Tasks.Alternera.WasmHost`).

The first two are the operator's to set and are trusted as they are:
no checksum is checked (`--fetch` checks one for the third), only that
the file is executable (`available/0`), and the program runs with the
node's privileges.

The engine settings (`args/1`) are the same for the serving processes
and the compile process, so a module compiled by one loads in the
others: the node's ceiling per call (`MemoryLimit.ceiling_mib/0`), how
many instances a process may hold at once (one per nested call, the
runner's depth limit plus one) and how much of a reset instance's
memory stays resident (`:keep_resident_bytes`, 2 MiB).

# `args`

```elixir
@spec args() :: [String.t()]
```

The engine settings, after the mode's own arguments.

# `available`

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

`:ok` when the binary is there and executable, else why not, in words
that name the path. Does not start it.

# `available?`

```elixir
@spec available?() :: boolean()
```

Whether `available/0` is `:ok`.

# `env`

```elixir
@spec env() :: [{charlist(), charlist() | false}]
```

The host's environment for `Port.open/2`. It reads its settings from its
arguments and runs tenants' modules, so it is given nothing of the node's
environment beyond what a process needs to start and write a temp file.

# `fingerprint`

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

A fingerprint of the binary and its engine settings: a compiled module
is named by it, so a file compiled by another build or other settings
is never loaded. Kept once per path and recomputed when the settings,
the size, the modification time or the inode change, so a binary
rebuilt while the node runs gets a new one: `mix alternera.wasm_host`
installs by rename, a new inode even within the same second.

# `instances`

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

How many instances one process may hold at once.

# `name`

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

The program's file name.

# `path`

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

The binary's path; it may not exist (`available/0`).

# `target`

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

The Rust target this node runs on: `aarch64-apple-darwin`,
`x86_64-apple-darwin`, `x86_64-unknown-linux-gnu` or
`aarch64-unknown-linux-gnu`; another
machine's is named as the BEAM names it.

---

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