# `Wasmex.Components.HostResource.Discovery`

Discovers host-owned resources imported by a WIT world.

Use `from_wit/2` for a self-contained WIT source string. Use `from_path/2`
for a WIT file or directory; directories can contain a `deps` subdirectory
with dependency packages.

Both functions accept `:world` when a package defines multiple worlds.
`from_wit/2` also accepts `:path` for parser diagnostics. The corresponding
resource lookup functions accept `:interface` to disambiguate resources
with the same name.

# `function_info`

```elixir
@type function_info() :: %{
  wit_name: String.t(),
  canonical_name: String.t(),
  elixir_name: String.t(),
  kind: function_kind(),
  arity: non_neg_integer(),
  has_return: boolean()
}
```

# `function_kind`

```elixir
@type function_kind() ::
  :constructor | :method | :async_method | :static | :async_static
```

# `resource_info`

```elixir
@type resource_info() :: %{
  name: String.t(),
  interface: String.t(),
  interface_path: [String.t()],
  functions: [function_info()]
}
```

# `from_path`

```elixir
@spec from_path(
  Path.t(),
  keyword()
) :: {:ok, [resource_info()]} | {:error, String.t()}
```

Discovers imported resources from a WIT file or directory.

When `path` is a directory, its `deps` subdirectory is resolved using the
standard WIT package layout.

# `from_wit`

```elixir
@spec from_wit(
  String.t(),
  keyword()
) :: {:ok, [resource_info()]} | {:error, String.t()}
```

Discovers imported resources from self-contained WIT source text.

The `:path` option labels parser diagnostics and defaults to `"wit"`.

# `get_resource_from_path`

```elixir
@spec get_resource_from_path(Path.t(), String.t() | atom(), keyword()) ::
  {:ok, resource_info()} | {:error, :not_found | String.t()}
```

Finds one imported resource in a WIT file or directory.

# `get_resource_from_wit`

```elixir
@spec get_resource_from_wit(String.t(), String.t() | atom(), keyword()) ::
  {:ok, resource_info()} | {:error, :not_found | String.t()}
```

Finds one imported resource in self-contained WIT source text.

---

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