Wasmex.Components.GuestResource.Discovery (wasmex v0.15.1)

Copy Markdown

Discovers guest-owned resources exported by a WIT world.

The returned metadata includes the component's real interface export name, including its package namespace and version. It can therefore be used directly for dynamic Wasmtime export lookup without guessing a package path.

Summary

Functions

Returns metadata for all guest resources exported by the selected WIT world.

Finds one exported guest resource by its WIT name.

Types

function_info()

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

function_kind()

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

resource_info()

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

Functions

from_wit(wit, options \\ [])

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

Returns metadata for all guest resources exported by the selected WIT world.

:path is used in parser diagnostics and defaults to "wit". Pass :world when the WIT contains more than one world.

get_resource_from_wit(wit, resource_name, options \\ [])

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

Finds one exported guest resource by its WIT name.