Documentation
¶
Overview ¶
Package prost provides a Go wrapper for running protoc-gen-prost via WASI/wazero.
Index ¶
- Constants
- Variables
- func CompileProtocGenProst(ctx context.Context, r wazero.Runtime) (wazero.CompiledModule, error)
- type ProtocGenProst
- func NewProtocGenProst(ctx context.Context, r wazero.Runtime) (*ProtocGenProst, error)
- func NewProtocGenProstWithModule(ctx context.Context, r wazero.Runtime, compiled wazero.CompiledModule) (*ProtocGenProst, error)
- func NewProtocGenProstWithWASI(ctx context.Context, r wazero.Runtime) (*ProtocGenProst, error)
- func NewProtocGenProstWithWASIAndModule(ctx context.Context, r wazero.Runtime, compiled wazero.CompiledModule) (*ProtocGenProst, error)
Constants ¶
const ( // ExportProstExecute executes the prost plugin. // Signature: prost_execute(input_ptr: i32, input_len: i32) -> i32 (output_len) ExportProstExecute = "prost_execute" // ExportProstGetOutputPtr returns the pointer to the output buffer. // Signature: prost_get_output_ptr() -> i32 (ptr) ExportProstGetOutputPtr = "prost_get_output_ptr" // ExportProstGetOutputLen returns the length of the output buffer. // Signature: prost_get_output_len() -> i32 (len) ExportProstGetOutputLen = "prost_get_output_len" // ExportProstClearOutput clears the output buffer. // Signature: prost_clear_output() -> void ExportProstClearOutput = "prost_clear_output" )
Prost plugin exports
const ( // ExportProstMalloc allocates memory in WASM linear memory. // Signature: prost_malloc(size: i32) -> i32 (pointer) ExportProstMalloc = "prost_malloc" // ExportProstFree frees memory in WASM linear memory. // Signature: prost_free(ptr: i32, size: i32) -> void ExportProstFree = "prost_free" )
Memory management exports
const ( // Version is the protoc-gen-prost version Version = "v0.5.0-wasi" // DownloadURL is the URL where this WASM file was downloaded from DownloadURL = "https://github.com/aperturerobotics/protoc-gen-prost/releases/download/v0.5.0-wasi/protoc-gen-prost.wasm" )
protoc-gen-prost WASI version information
const ProtocGenProstWASMFilename = "protoc-gen-prost.wasm"
ProtocGenProstWASMFilename is the filename for ProtocGenProstWASM.
Variables ¶
var ProtocGenProstWASM []byte
ProtocGenProstWASM contains the binary contents of the protoc-gen-prost WASI build.
This is a WASM binary that exports functions for executing the Prost protobuf code generator. The module uses the standard WASI preview1 interface.
Functions ¶
func CompileProtocGenProst ¶
CompileProtocGenProst compiles the embedded protoc-gen-prost WASM module. The compiled module can be reused across multiple ProtocGenProst instances.
Types ¶
type ProtocGenProst ¶
type ProtocGenProst struct {
// contains filtered or unexported fields
}
ProtocGenProst wraps a protoc-gen-prost WASI module providing a high-level API for executing the Prost protobuf code generator.
func NewProtocGenProst ¶
NewProtocGenProst creates a new ProtocGenProst instance using the embedded WASM. This instantiates WASI on the runtime. For shared runtimes where WASI is already instantiated, use NewProtocGenProstWithWASI instead. Call Close() when done to release resources.
func NewProtocGenProstWithModule ¶
func NewProtocGenProstWithModule(ctx context.Context, r wazero.Runtime, compiled wazero.CompiledModule) (*ProtocGenProst, error)
NewProtocGenProstWithModule creates a new ProtocGenProst instance using a pre-compiled module. This instantiates WASI on the runtime. For shared runtimes where WASI is already instantiated, use NewProtocGenProstWithWASIAndModule instead.
func NewProtocGenProstWithWASI ¶
NewProtocGenProstWithWASI creates a new ProtocGenProst instance on a runtime that already has WASI instantiated. Use this when sharing a runtime with other WASM modules (e.g., protoc).
func NewProtocGenProstWithWASIAndModule ¶
func NewProtocGenProstWithWASIAndModule(ctx context.Context, r wazero.Runtime, compiled wazero.CompiledModule) (*ProtocGenProst, error)
NewProtocGenProstWithWASIAndModule creates a new ProtocGenProst instance using a pre-compiled module on a runtime that already has WASI instantiated.
func (*ProtocGenProst) Close ¶
func (p *ProtocGenProst) Close(ctx context.Context) error
Close releases resources associated with the ProtocGenProst instance.