// Code generated by ndpgen. DO NOT EDIT.//// This file contains client wrappers for the Codec host service.// It is intended for use in Navidrome plugins built with TinyGo.////go:build wasip1package ndhostimport ("encoding/json""errors""github.com/navidrome/navidrome/plugins/pdk/go/pdk")// codec_encode is the host function provided by Navidrome.////go:wasmimport extism:host/user codec_encodefunc codec_encode(uint64) uint64type codecEncodeRequest struct {Data []byte `json:"data"`}type codecEncodeResponse struct {Result []byte `json:"result,omitempty"`Error string `json:"error,omitempty"`}// CodecEncode calls the codec_encode host function.func CodecEncode(data []byte) ([]byte, error) {// Marshal request to JSONreq := codecEncodeRequest{Data: data,}reqBytes, err := json.Marshal(req)if err != nil {return nil, err}reqMem := pdk.AllocateBytes(reqBytes)defer reqMem.Free()// Call the host functionresponsePtr := codec_encode(reqMem.Offset())// Read the response from memoryresponseMem := pdk.FindMemory(responsePtr)responseBytes := responseMem.ReadBytes()// Parse the responsevar response codecEncodeResponseif err := json.Unmarshal(responseBytes, &response); err != nil {return nil, err}// Convert Error field to Go errorif response.Error != "" {return nil, errors.New(response.Error)}return response.Result, nil}