WasmComponentInstance Class

An instance of a component, or an instance exported by a component: its exports.

public sealed class WasmComponentInstance

Properties

NameDescription
ExportsGets the names and the kinds of the exports.

Gets the names and the kinds of the exports.

public IReadOnlyList<WasmComponentImport> Exports { get; }

Methods

NameDescription
GetFunction(string)Returns an exported function, or null. A name of the form instance#function (such as wasi:cli/run@0.2.0#run) is a function of an exported instance.
GetInstance(string)Returns an exported instance, or null.
GetType(string)Returns an exported type (such as a resource type), or null.
Run<T>(Func<Task<T>>)Runs an asynchronous operation of the host on the current thread, as the thread of the store, and returns its result: while the operation waits for the components (the values of their streams and futures, the tasks that continue after a call returns), the store runs them, and the continuations of the operation run on this thread. The operation can call the functions of the components and use their streams.

GetFunction(string)

WasmComponent.cs

Returns an exported function, or null. A name of the form instance#function (such as wasi:cli/run@0.2.0#run) is a function of an exported instance.

public ComponentFunction? GetFunction(string name)

Parameters

name string
The name of the export.

Returns

ComponentFunction?

GetInstance(string)

WasmComponent.cs

Returns an exported instance, or null.

public WasmComponentInstance? GetInstance(string name)

Parameters

name string
The name of the export.

Returns

WasmComponentInstance?

GetType(string)

WasmComponent.cs

Returns an exported type (such as a resource type), or null.

public ComponentType? GetType(string name)

Parameters

name string
The name of the export.

Returns

ComponentType?

Run<T>(Func<Task<T>>)

WasmComponent.cs

Runs an asynchronous operation of the host on the current thread, as the thread of the store, and returns its result: while the operation waits for the components (the values of their streams and futures, the tasks that continue after a call returns), the store runs them, and the continuations of the operation run on this thread. The operation can call the functions of the components and use their streams.

public T Run<T>(Func<Task<T>> operation)

Type parameters

T
The type of the result.

Parameters

operation Func<Task<T>>
The operation.

Returns

T The result of the operation.

Exceptions

WasmTrapException
A component trapped, or the components cannot complete the operation (a deadlock).
PlatformNotSupportedException
The operation waits for the host on the browser.