// Code generated by ndpgen. DO NOT EDIT.//// This file contains client wrappers for the Search 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")// Result represents the Result data structure.type Result struct {ID string `json:"id"`}// search_find is the host function provided by Navidrome.////go:wasmimport extism:host/user search_findfunc search_find(uint64) uint64type searchFindRequest struct {Query string `json:"query"`}type searchFindResponse struct {Results []Result `json:"results,omitempty"`Total int32 `json:"total,omitempty"`Error string `json:"error,omitempty"`}// SearchFind calls the search_find host function.func SearchFind(query string) ([]Result, int32, error) {// Marshal request to JSONreq := searchFindRequest{Query: query,}reqBytes, err := json.Marshal(req)if err != nil {return nil, 0, err}reqMem := pdk.AllocateBytes(reqBytes)defer reqMem.Free()// Call the host functionresponsePtr := search_find(reqMem.Offset())// Read the response from memoryresponseMem := pdk.FindMemory(responsePtr)responseBytes := responseMem.ReadBytes()// Parse the responsevar response searchFindResponseif err := json.Unmarshal(responseBytes, &response); err != nil {return nil, 0, err}// Convert Error field to Go errorif response.Error != "" {return nil, 0, errors.New(response.Error)}return response.Results, response.Total, nil}