Show / Hide Table of Contents

Class Module

Represents a WebAssembly module.

Inheritance
System.Object
Module
Namespace: Wasmtime
Assembly: Wasmtime.Dotnet.dll
Syntax
public class Module : IDisposable

Properties

| Improve this Doc View Source

Exports

The exports of the module.

Declaration
public IReadOnlyList<Export> Exports { get; }
Property Value
Type Description
IReadOnlyList<Export>
| Improve this Doc View Source

Imports

The imports of the module.

Declaration
public IReadOnlyList<Import> Imports { get; }
Property Value
Type Description
IReadOnlyList<Import>
| Improve this Doc View Source

Name

The name of the module.

Declaration
public string Name { get; }
Property Value
Type Description
System.String

Methods

| Improve this Doc View Source

ConvertText(String)

Convert WAT (Web Assembly Text) into WASM bytes

Declaration
public static byte[] ConvertText(string wat)
Parameters
Type Name Description
System.String wat

A string containing WAT (Web Assembly Text)

Returns
Type Description
System.Byte[]

Returns a byte array containing the WebAssembly module represented by the given text.

Exceptions
Type Condition
WasmtimeException

Thrown if text is not valid WAT

| Improve this Doc View Source

Deserialize(Engine, String, ReadOnlySpan<Byte>)

Deserializes a previously serialized module from a span of bytes.

Declaration
public static Module Deserialize(Engine engine, string name, ReadOnlySpan<byte> bytes)
Parameters
Type Name Description
Engine engine

The engine to use to deserialize the module.

System.String name

The name of the module being deserialized.

ReadOnlySpan<System.Byte> bytes

The previously serialized module bytes.

Returns
Type Description
Module

Returns the Module that was previously serialized.

Remarks

The passed bytes must come from a previous call to Serialize().

| Improve this Doc View Source

DeserializeFile(Engine, String, String)

Deserializes a previously serialized module from a file.

Declaration
public static Module DeserializeFile(Engine engine, string name, string path)
Parameters
Type Name Description
Engine engine

The engine to deserialize the module with.

System.String name

The name of the deserialized module.

System.String path

The path to the previously serialized module.

Returns
Type Description
Module

Returns the Module that was previously serialized.

Remarks

The file's contents must come from a previous call to Serialize().

| Improve this Doc View Source

Dispose()

Declaration
public void Dispose()
| Improve this Doc View Source

FromBytes(Engine, String, ReadOnlySpan<Byte>)

Creates a Module given the module name and bytes.

Declaration
public static Module FromBytes(Engine engine, string name, ReadOnlySpan<byte> bytes)
Parameters
Type Name Description
Engine engine

The engine to use for the module.

System.String name

The name of the module.

ReadOnlySpan<System.Byte> bytes

The bytes of the module.

Returns
Type Description
Module

Returns a new Module.

| Improve this Doc View Source

FromFile(Engine, String)

Creates a Module given the path to the WebAssembly file.

Declaration
public static Module FromFile(Engine engine, string path)
Parameters
Type Name Description
Engine engine

The engine to use for the module.

System.String path

The path to the WebAssembly file.

Returns
Type Description
Module

Returns a new Module.

| Improve this Doc View Source

FromStream(Engine, String, Stream)

Creates a Module from a stream.

Declaration
public static Module FromStream(Engine engine, string name, Stream stream)
Parameters
Type Name Description
Engine engine

The engine to use for the module.

System.String name

The name of the module.

Stream stream

The stream of the module data.

Returns
Type Description
Module

Returns a new Module.

| Improve this Doc View Source

FromText(Engine, String, String)

Creates a Module based on a WebAssembly text format representation.

Declaration
public static Module FromText(Engine engine, string name, string text)
Parameters
Type Name Description
Engine engine

The engine to use for the module.

System.String name

The name of the module.

System.String text

The WebAssembly text format representation of the module.

Returns
Type Description
Module

Returns a new Module.

| Improve this Doc View Source

FromTextFile(Engine, String)

Creates a Module based on the path to a WebAssembly text format file.

Declaration
public static Module FromTextFile(Engine engine, string path)
Parameters
Type Name Description
Engine engine

The engine to use for the module.

System.String path

The path to the WebAssembly text format file.

Returns
Type Description
Module

Returns a new Module.

| Improve this Doc View Source

FromTextStream(Engine, String, Stream)

Creates a Module from a WebAssembly text format stream.

Declaration
public static Module FromTextStream(Engine engine, string name, Stream stream)
Parameters
Type Name Description
Engine engine

The engine to use for the module.

System.String name

The name of the module.

Stream stream

The stream of the module data.

Returns
Type Description
Module

Returns a new Module.

| Improve this Doc View Source

Serialize()

Serializes the module to an array of bytes.

Declaration
public byte[] Serialize()
Returns
Type Description
System.Byte[]

Returns the serialized module as an array of bytes.

| Improve this Doc View Source

Validate(Engine, ReadOnlySpan<Byte>)

Validates the given WebAssembly module.

Declaration
public static string? Validate(Engine engine, ReadOnlySpan<byte> bytes)
Parameters
Type Name Description
Engine engine

The engine to use for validation.

ReadOnlySpan<System.Byte> bytes

The bytes of the WebAssembly module to validate.

Returns
Type Description
System.Nullable<System.String>

Returns null if the module is valid or an error message if the module is invalid.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX