// Code generated by ndpgen. DO NOT EDIT.//// This file contains client wrappers for the Users 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")// User represents the User data structure.type User struct {ID string `json:"id"`Name string `json:"name"`}// users_get is the host function provided by Navidrome.////go:wasmimport extism:host/user users_getfunc users_get(uint64) uint64type usersGetRequest struct {Id *string `json:"id"`Filter *User `json:"filter"`}type usersGetResponse struct {Result *User `json:"result,omitempty"`Error string `json:"error,omitempty"`}// UsersGet calls the users_get host function.func UsersGet(id *string, filter *User) (*User, error) {// Marshal request to JSONreq := usersGetRequest{Id: id,Filter: filter,}reqBytes, err := json.Marshal(req)if err != nil {return nil, err}reqMem := pdk.AllocateBytes(reqBytes)defer reqMem.Free()// Call the host functionresponsePtr := users_get(reqMem.Offset())// Read the response from memoryresponseMem := pdk.FindMemory(responsePtr)responseBytes := responseMem.ReadBytes()// Parse the responsevar response usersGetResponseif 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}