Class PanamaWasiContext

java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaWasiContext
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.wasi.WasiContext

public final class PanamaWasiContext extends Object implements ai.tegmentum.wasmtime4j.wasi.WasiContext
Panama FFI implementation of WasiContext.

Provides WASI context functionality using Panama Foreign Function API bindings to the native Wasmtime WASI implementation.

Since:
1.0.0
  • Constructor Details

    • PanamaWasiContext

      public PanamaWasiContext()
      Creates a new Panama WASI context.
  • Method Details

    • getNativeContext

      public MemorySegment getNativeContext()
      Gets the native context handle.
      Returns:
      the native context memory segment
    • setArgv

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setArgv(String[] argv)
      Specified by:
      setArgv in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setEnv

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setEnv(String key, String value)
      Specified by:
      setEnv in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setEnv

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setEnv(Map<String,String> env)
      Specified by:
      setEnv in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • inheritEnv

      public ai.tegmentum.wasmtime4j.wasi.WasiContext inheritEnv()
      Specified by:
      inheritEnv in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • inheritArgs

      public ai.tegmentum.wasmtime4j.wasi.WasiContext inheritArgs()
      Specified by:
      inheritArgs in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • inheritStdio

      public ai.tegmentum.wasmtime4j.wasi.WasiContext inheritStdio()
      Specified by:
      inheritStdio in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setStdin

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setStdin(Path path)
      Specified by:
      setStdin in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setStdinBytes

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setStdinBytes(byte[] data)
      Specified by:
      setStdinBytes in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setStdout

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setStdout(Path path)
      Specified by:
      setStdout in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setStderr

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setStderr(Path path)
      Specified by:
      setStderr in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setStdoutAppend

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setStdoutAppend(Path path)
      Specified by:
      setStdoutAppend in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setStderrAppend

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setStderrAppend(Path path)
      Specified by:
      setStderrAppend in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • preopenedDir

      public ai.tegmentum.wasmtime4j.wasi.WasiContext preopenedDir(Path hostPath, String guestPath) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      preopenedDir in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • preopenedDirReadOnly

      public ai.tegmentum.wasmtime4j.wasi.WasiContext preopenedDirReadOnly(Path hostPath, String guestPath) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      preopenedDirReadOnly in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • setWorkingDirectory

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setWorkingDirectory(String workingDir)
      Specified by:
      setWorkingDirectory in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setNetworkEnabled

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setNetworkEnabled(boolean enabled)
      Specified by:
      setNetworkEnabled in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setMaxOpenFiles

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setMaxOpenFiles(int maxFds)
      Specified by:
      setMaxOpenFiles in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setAsyncIoEnabled

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setAsyncIoEnabled(boolean enabled)
      Specified by:
      setAsyncIoEnabled in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setMaxAsyncOperations

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setMaxAsyncOperations(int maxOps)
      Specified by:
      setMaxAsyncOperations in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setAsyncTimeout

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setAsyncTimeout(long timeoutMs)
      Specified by:
      setAsyncTimeout in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setComponentModelEnabled

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setComponentModelEnabled(boolean enabled)
      Specified by:
      setComponentModelEnabled in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setProcessEnabled

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setProcessEnabled(boolean enabled)
      Specified by:
      setProcessEnabled in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • setFilesystemWorkingDir

      public ai.tegmentum.wasmtime4j.wasi.WasiContext setFilesystemWorkingDir(Path workingDir)
      Specified by:
      setFilesystemWorkingDir in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • isNetworkEnabled

      public boolean isNetworkEnabled()
      Returns whether network access is enabled.
      Returns:
      true if network access is enabled
    • isAsyncIoEnabled

      public boolean isAsyncIoEnabled()
      Returns whether async I/O is enabled.
      Returns:
      true if async I/O is enabled
    • isProcessEnabled

      public boolean isProcessEnabled()
      Returns whether process spawning is enabled.
      Returns:
      true if process spawning is enabled
    • isComponentModelEnabled

      public boolean isComponentModelEnabled()
      Returns whether component model is enabled.
      Returns:
      true if component model is enabled
    • getMaxAsyncOperations

      public int getMaxAsyncOperations()
      Returns the max async operations limit.
      Returns:
      the max async operations (-1 = unlimited)
    • getAsyncTimeoutMs

      public long getAsyncTimeoutMs()
      Returns the async timeout in milliseconds.
      Returns:
      the async timeout (-1 = no timeout)
    • getEnvironment

      public Map<String,String> getEnvironment()
      Specified by:
      getEnvironment in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • getArguments

      public List<String> getArguments()
      Specified by:
      getArguments in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • enableOutputCapture

      public ai.tegmentum.wasmtime4j.wasi.WasiContext enableOutputCapture() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      enableOutputCapture in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getStdoutCapture

      public byte[] getStdoutCapture()
      Specified by:
      getStdoutCapture in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • getStderrCapture

      public byte[] getStderrCapture()
      Specified by:
      getStderrCapture in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • hasStdoutCapture

      public boolean hasStdoutCapture()
      Specified by:
      hasStdoutCapture in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • hasStderrCapture

      public boolean hasStderrCapture()
      Specified by:
      hasStderrCapture in interface ai.tegmentum.wasmtime4j.wasi.WasiContext
    • getNativeHandle

      public MemorySegment getNativeHandle()
      Gets the native context handle.
      Returns:
      the native context handle
    • close

      public void close()
      Closes this WASI context and releases native resources.