Class PanamaWasiLinker

java.lang.Object
ai.tegmentum.wasmtime4j.panama.wasi.PanamaWasiLinker
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.wasi.WasiLinker, Closeable, AutoCloseable

public final class PanamaWasiLinker extends Object implements ai.tegmentum.wasmtime4j.wasi.WasiLinker
Panama implementation of a WASI-enabled linker.

This linker wraps a standard Panama linker and adds WASI functionality. Configuration methods store settings that are applied when instantiate(Store, Module) is called.

The linker accumulates configuration through method calls and creates a properly configured WASI context at instantiation time. This allows for flexible, incremental configuration of WASI settings.

Since:
1.0.0
  • Constructor Details

    • PanamaWasiLinker

      public PanamaWasiLinker(PanamaLinker<Object> linker, PanamaEngine engine, ai.tegmentum.wasmtime4j.wasi.WasiConfig config)
      Creates a new WASI linker with the specified configuration.
      Parameters:
      linker - the Panama linker instance
      engine - the engine
      config - initial WASI configuration (may be null for defaults)
  • Method Details

    • allowDirectoryAccess

      public void allowDirectoryAccess(Path hostPath, String guestPath) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      allowDirectoryAccess in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • setEnvironmentVariable

      public void setEnvironmentVariable(String name, String value)
      Specified by:
      setEnvironmentVariable in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
    • setEnvironmentVariables

      public void setEnvironmentVariables(Map<String,String> environment)
      Specified by:
      setEnvironmentVariables in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
    • inheritEnvironment

      public void inheritEnvironment() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      inheritEnvironment in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • inheritEnvironmentVariables

      public void inheritEnvironmentVariables(List<String> variableNames) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      inheritEnvironmentVariables in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • setArguments

      public void setArguments(List<String> args)
      Specified by:
      setArguments in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
    • configureStdin

      public void configureStdin(ai.tegmentum.wasmtime4j.wasi.WasiStdioConfig config) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      configureStdin in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • configureStdout

      public void configureStdout(ai.tegmentum.wasmtime4j.wasi.WasiStdioConfig config) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      configureStdout in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • configureStderr

      public void configureStderr(ai.tegmentum.wasmtime4j.wasi.WasiStdioConfig config) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      configureStderr in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • enableNetworkAccess

      public void enableNetworkAccess() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      enableNetworkAccess in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • disableNetworkAccess

      public void disableNetworkAccess()
      Specified by:
      disableNetworkAccess in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
    • setMaxFileSize

      public void setMaxFileSize(Long maxSizeBytes)
      Specified by:
      setMaxFileSize in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
    • setMaxOpenFiles

      public void setMaxOpenFiles(Integer max)
      Specified by:
      setMaxOpenFiles in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
    • instantiate

      public ai.tegmentum.wasmtime4j.Instance instantiate(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.Module module) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      instantiate in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getLinker

      public ai.tegmentum.wasmtime4j.Linker<?> getLinker()
      Specified by:
      getLinker in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
    • getEngine

      public ai.tegmentum.wasmtime4j.Engine getEngine()
      Specified by:
      getEngine in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
    • getConfig

      public ai.tegmentum.wasmtime4j.wasi.WasiConfig getConfig()
      Specified by:
      getConfig in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ai.tegmentum.wasmtime4j.wasi.WasiLinker