mirror of
https://github.com/navidrome/navidrome.git
synced 2026-02-02 06:24:14 +00:00
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
// Code generated by hostgen. DO NOT EDIT.
|
|
//
|
|
// This file contains client wrappers for the Codec host service.
|
|
// It is intended for use in Navidrome plugins built with TinyGo.
|
|
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/extism/go-pdk"
|
|
)
|
|
|
|
// codec_encode is the host function provided by Navidrome.
|
|
//
|
|
//go:wasmimport extism:host/user codec_encode
|
|
func codec_encode(uint64) uint64
|
|
|
|
// CodecEncodeResponse is the response type for Codec.Encode.
|
|
type CodecEncodeResponse struct {
|
|
Result []byte `json:"result,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
// CodecEncode calls the codec_encode host function.
|
|
func CodecEncode(data []byte) (*CodecEncodeResponse, error) {
|
|
dataMem := pdk.AllocateBytes(data)
|
|
defer dataMem.Free()
|
|
|
|
// Call the host function
|
|
responsePtr := codec_encode(dataMem.Offset())
|
|
|
|
// Read the response from memory
|
|
responseMem := pdk.FindMemory(responsePtr)
|
|
responseBytes := responseMem.ReadBytes()
|
|
|
|
// Parse the response
|
|
var response CodecEncodeResponse
|
|
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &response, nil
|
|
}
|