Show / Hide Table of Contents

Class Store

Represents a Wasmtime store.

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

A Wasmtime store may be sent between threads but cannot be used from more than one thread simultaneously.

Constructors

| Improve this Doc View Source

Store(Engine)

Constructs a new store.

Declaration
public Store(Engine engine)
Parameters
Type Name Description
Engine engine

The engine to use for the store.

| Improve this Doc View Source

Store(Engine, Nullable<Object>)

Constructs a new store with the given context data.

Declaration
public Store(Engine engine, object? data)
Parameters
Type Name Description
Engine engine

The engine to use for the store.

System.Nullable<System.Object> data

The data to initialize the store with; this can later be accessed with the GetData function.

Methods

| Improve this Doc View Source

AddFuel(UInt64)

Adds fuel to this store for WebAssembly code to consume while executing.

Declaration
public void AddFuel(ulong fuel)
Parameters
Type Name Description
System.UInt64 fuel

The fuel to add to the store.

| Improve this Doc View Source

ConsumeFuel(UInt64)

Synthetically consumes fuel from this store.

For this method to work fuel consumption must be enabled via WithFuelConsumption(Boolean).

WebAssembly execution will automatically consume fuel but if so desired the embedder can also consume fuel manually to account for relative costs of host functions, for example.

This method will attempt to consume fuel units of fuel from within this store. If the remaining amount of fuel allows this then the amount of remaining fuel is returned. Otherwise, a WasmtimeException is thrown and no fuel is consumed.

Declaration
public ulong ConsumeFuel(ulong fuel)
Parameters
Type Name Description
System.UInt64 fuel

The fuel to consume from the store.

Returns
Type Description
System.UInt64

Returns the remaining amount of fuel.

Exceptions
Type Condition
WasmtimeException

Thrown if more fuel is consumed than the store currently has.

| Improve this Doc View Source

Dispose()

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

GC()

Perform garbage collection within the given store.

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

GetConsumedFuel()

Gets the fuel consumed by the executing WebAssembly code.

Declaration
public ulong GetConsumedFuel()
Returns
Type Description
System.UInt64

Returns the fuel consumed by the executing WebAssembly code or 0 if fuel consumption was not enabled.

| Improve this Doc View Source

GetData()

Retrieves the data stored in the Store context

Declaration
public object? GetData()
Returns
Type Description
System.Nullable<System.Object>
| Improve this Doc View Source

SetData(Nullable<Object>)

Replaces the data stored in the Store context

Declaration
public void SetData(object? data)
Parameters
Type Name Description
System.Nullable<System.Object> data
| Improve this Doc View Source

SetEpochDeadline(UInt64)

Configures the relative deadline at which point WebAssembly code will trap.

Declaration
public void SetEpochDeadline(ulong ticksBeyondCurrent)
Parameters
Type Name Description
System.UInt64 ticksBeyondCurrent
| Improve this Doc View Source

SetWasiConfiguration(WasiConfiguration)

Configures WASI within the store.

Declaration
public void SetWasiConfiguration(WasiConfiguration config)
Parameters
Type Name Description
WasiConfiguration config

The WASI configuration to use.

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