Class PanamaComponentLinker<T>

java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaComponentLinker<T>
Type Parameters:
T - the type of user data associated with stores used with this linker
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.component.ComponentLinker<T>, Closeable, AutoCloseable

public final class PanamaComponentLinker<T> extends Object implements ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
Panama FFI implementation of ComponentLinker for WebAssembly Component Model.

This implementation uses Panama Foreign Function API to interact with the native Wasmtime library for Component Model operations.

Since:
1.0.0
  • Constructor Details

    • PanamaComponentLinker

      public PanamaComponentLinker(PanamaEngine engine) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Creates a new Panama component linker.
      Parameters:
      engine - the engine to create the linker for
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException - if linker creation fails
  • Method Details

    • defineFunction

      public void defineFunction(String interfaceNamespace, String interfaceName, String functionName, ai.tegmentum.wasmtime4j.component.ComponentHostFunction implementation) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      defineFunction in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • defineFunction

      public void defineFunction(String witPath, ai.tegmentum.wasmtime4j.component.ComponentHostFunction implementation) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      defineFunction in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • defineFunctionAsync

      public void defineFunctionAsync(String interfaceNamespace, String interfaceName, String functionName, ai.tegmentum.wasmtime4j.component.ComponentHostFunction implementation) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      defineFunctionAsync in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • defineFunctionAsync

      public void defineFunctionAsync(String witPath, ai.tegmentum.wasmtime4j.component.ComponentHostFunction implementation) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      defineFunctionAsync in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • defineInterface

      public void defineInterface(String interfaceNamespace, String interfaceName, Map<String,ai.tegmentum.wasmtime4j.component.ComponentHostFunction> functions) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      defineInterface in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • defineResource

      public void defineResource(String interfaceNamespace, String interfaceName, String resourceName, ai.tegmentum.wasmtime4j.component.ComponentResourceDefinition<?> resourceDefinition) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      defineResource in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • defineModule

      public void defineModule(String instancePath, String name, ai.tegmentum.wasmtime4j.Module module) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      defineModule in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • linkInstance

      public void linkInstance(ai.tegmentum.wasmtime4j.component.ComponentInstance instance) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      linkInstance in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • linkComponent

      public ai.tegmentum.wasmtime4j.component.ComponentInstance linkComponent(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.component.Component component) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      linkComponent in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • instantiatePre

      public ai.tegmentum.wasmtime4j.component.ComponentInstancePre instantiatePre(ai.tegmentum.wasmtime4j.component.Component component) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      instantiatePre in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • instantiate

      public ai.tegmentum.wasmtime4j.component.ComponentInstance instantiate(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.component.Component component) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      instantiate in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • enableWasiPreview2

      public void enableWasiPreview2() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      enableWasiPreview2 in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • enableWasiPreview2

      public void enableWasiPreview2(ai.tegmentum.wasmtime4j.wasi.WasiPreview2Config config) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      enableWasiPreview2 in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • enableWasiHttp

      public void enableWasiHttp() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      enableWasiHttp in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • enableWasiHttp

      public void enableWasiHttp(ai.tegmentum.wasmtime4j.wasi.http.WasiHttpConfig config) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      enableWasiHttp in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • enableWasiP3

      public void enableWasiP3() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      enableWasiP3 in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • enableWasiHttpP3

      public void enableWasiHttpP3() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      enableWasiHttpP3 in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • enableWasiConfig

      public void enableWasiConfig() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      enableWasiConfig in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • setConfigVariables

      public void setConfigVariables(Map<String,String> variables) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      setConfigVariables in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getEngine

      public ai.tegmentum.wasmtime4j.Engine getEngine()
      Specified by:
      getEngine in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • hasInterface

      public boolean hasInterface(String interfaceNamespace, String interfaceName)
      Specified by:
      hasInterface in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • hasFunction

      public boolean hasFunction(String interfaceNamespace, String interfaceName, String functionName)
      Specified by:
      hasFunction in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • getDefinedInterfaces

      public Set<String> getDefinedInterfaces()
      Specified by:
      getDefinedInterfaces in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • getDefinedFunctions

      public Set<String> getDefinedFunctions(String interfaceNamespace, String interfaceName)
      Specified by:
      getDefinedFunctions in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • isWasiP2Enabled

      public boolean isWasiP2Enabled()
      Specified by:
      isWasiP2Enabled in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • isWasiHttpEnabled

      public boolean isWasiHttpEnabled()
      Specified by:
      isWasiHttpEnabled in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • getHostFunctionCount

      public int getHostFunctionCount()
      Specified by:
      getHostFunctionCount in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • getInterfaceCount

      public int getInterfaceCount()
      Specified by:
      getInterfaceCount in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • setAsyncSupport

      public void setAsyncSupport(boolean enabled) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      setAsyncSupport in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • setWasiMaxRandomSize

      public void setWasiMaxRandomSize(long maxSize) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      setWasiMaxRandomSize in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • aliasInterface

      public void aliasInterface(String fromNamespace, String fromInterface, String toNamespace, String toInterface) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      aliasInterface in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • allowShadowing

      public void allowShadowing(boolean allow)
      Specified by:
      allowShadowing in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • defineUnknownImportsAsTraps

      public void defineUnknownImportsAsTraps(ai.tegmentum.wasmtime4j.component.Component component) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      defineUnknownImportsAsTraps in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • substitutedComponentType

      public ai.tegmentum.wasmtime4j.component.ComponentTypeInfo substitutedComponentType(ai.tegmentum.wasmtime4j.component.Component component) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      substitutedComponentType in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ai.tegmentum.wasmtime4j.component.ComponentLinker<T>
    • getNativeLinker

      public MemorySegment getNativeLinker()
      Gets the native component linker pointer.
      Returns:
      native linker memory segment