Class PanamaWitValueMarshaller

java.lang.Object
ai.tegmentum.wasmtime4j.panama.wit.PanamaWitValueMarshaller

public final class PanamaWitValueMarshaller extends Object
Panama implementation of WIT value marshaller.

This class provides bidirectional marshalling between Java WIT values and the binary format used by native Wasmtime component runtime. It delegates to native Rust functions for actual marshalling work to ensure consistency with Wasmtime's expectations.

The marshalling process:

  1. Java WIT values are serialized using WitValueSerializer
  2. Serialized bytes are passed to native marshalling functions
  3. Native code validates and potentially transforms the data
  4. Result is returned as marshalled bytes ready for component calls
Since:
1.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static ai.tegmentum.wasmtime4j.wit.WitValueMarshaller.MarshalledValue
    marshal(ai.tegmentum.wasmtime4j.wit.WitValue value, Arena arena)
    Marshals a WIT value to binary format for native use.
    static ai.tegmentum.wasmtime4j.wit.WitValue
    unmarshal(int typeDiscriminator, byte[] data, Arena arena)
    Unmarshals a WIT value from binary format.
    static boolean
    validateDiscriminator(int typeDiscriminator)
    Validates a type discriminator.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • marshal

      public static ai.tegmentum.wasmtime4j.wit.WitValueMarshaller.MarshalledValue marshal(ai.tegmentum.wasmtime4j.wit.WitValue value, Arena arena) throws ai.tegmentum.wasmtime4j.exception.ValidationException
      Marshals a WIT value to binary format for native use.
      Parameters:
      value - the WIT value to marshal
      arena - the memory arena for allocation
      Returns:
      marshalled value ready for native calls
      Throws:
      ai.tegmentum.wasmtime4j.exception.ValidationException - if marshalling fails
    • unmarshal

      public static ai.tegmentum.wasmtime4j.wit.WitValue unmarshal(int typeDiscriminator, byte[] data, Arena arena) throws ai.tegmentum.wasmtime4j.exception.ValidationException
      Unmarshals a WIT value from binary format.
      Parameters:
      typeDiscriminator - the type discriminator (1-8)
      data - the serialized byte array
      arena - the memory arena for allocation
      Returns:
      the unmarshalled WIT value
      Throws:
      ai.tegmentum.wasmtime4j.exception.ValidationException - if unmarshalling fails
    • validateDiscriminator

      public static boolean validateDiscriminator(int typeDiscriminator)
      Validates a type discriminator.
      Parameters:
      typeDiscriminator - the type discriminator to validate
      Returns:
      true if valid, false otherwise