Wasmex. Components. HostResource. Discovery
(wasmex v0.15.0)
Copy Markdown
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.
Summary
Functions
Discovers imported resources from a WIT file or directory.
Discovers imported resources from self-contained WIT source text.
Finds one imported resource in a WIT file or directory.
Finds one imported resource in self-contained WIT source text.
Types
@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() }
@type function_kind() ::
:constructor | :method | :async_method | :static | :async_static
@type resource_info() :: %{ name: String.t(), interface: String.t(), interface_path: [String.t()], functions: [function_info()] }
Functions
@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.
@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".
@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.
@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.