// Code generated by ndpgen. DO NOT EDIT.//// This file contains client wrappers for the Store 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")// Item represents the Item data structure.type Item struct {ID string `json:"id"`Name string `json:"name"`}// store_save is the host function provided by Navidrome.////go:wasmimport extism:host/user store_savefunc store_save(uint64) uint64type storeSaveRequest struct {Item Item `json:"item"`}type storeSaveResponse struct {Id string `json:"id,omitempty"`Error string `json:"error,omitempty"`}// StoreSave calls the store_save host function.func StoreSave(item Item) (string, error) {// Marshal request to JSONreq := storeSaveRequest{Item: item,}reqBytes, err := json.Marshal(req)if err != nil {return "", err}reqMem := pdk.AllocateBytes(reqBytes)defer reqMem.Free()// Call the host functionresponsePtr := store_save(reqMem.Offset())// Read the response from memoryresponseMem := pdk.FindMemory(responsePtr)responseBytes := responseMem.ReadBytes()// Parse the responsevar response storeSaveResponseif err := json.Unmarshal(responseBytes, &response); err != nil {return "", err}// Convert Error field to Go errorif response.Error != "" {return "", errors.New(response.Error)}return response.Id, nil}