// Code generated by ndpgen. DO NOT EDIT.//// This file contains client wrappers for the Config 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")// config_get is the host function provided by Navidrome.////go:wasmimport extism:host/user config_getfunc config_get(uint64) uint64// config_set is the host function provided by Navidrome.////go:wasmimport extism:host/user config_setfunc config_set(uint64) uint64// config_has is the host function provided by Navidrome.////go:wasmimport extism:host/user config_hasfunc config_has(uint64) uint64type configGetRequest struct {Key string `json:"key"`}type configGetResponse struct {Value string `json:"value,omitempty"`Exists bool `json:"exists,omitempty"`Error string `json:"error,omitempty"`}type configSetRequest struct {Key string `json:"key"`Value string `json:"value"`}type configHasRequest struct {Key string `json:"key"`}type configHasResponse struct {Exists bool `json:"exists,omitempty"`Error string `json:"error,omitempty"`}// ConfigGet calls the config_get host function.func ConfigGet(key string) (string, bool, error) {// Marshal request to JSONreq := configGetRequest{Key: key,}reqBytes, err := json.Marshal(req)if err != nil {return "", false, err}reqMem := pdk.AllocateBytes(reqBytes)defer reqMem.Free()// Call the host functionresponsePtr := config_get(reqMem.Offset())// Read the response from memoryresponseMem := pdk.FindMemory(responsePtr)responseBytes := responseMem.ReadBytes()// Parse the responsevar response configGetResponseif err := json.Unmarshal(responseBytes, &response); err != nil {return "", false, err}// Convert Error field to Go errorif response.Error != "" {return "", false, errors.New(response.Error)}return response.Value, response.Exists, nil}// ConfigSet calls the config_set host function.func ConfigSet(key string, value string) error {// Marshal request to JSONreq := configSetRequest{Key: key,Value: value,}reqBytes, err := json.Marshal(req)if err != nil {return err}reqMem := pdk.AllocateBytes(reqBytes)defer reqMem.Free()// Call the host functionresponsePtr := config_set(reqMem.Offset())// Read the response from memoryresponseMem := pdk.FindMemory(responsePtr)responseBytes := responseMem.ReadBytes()// Parse error-only responsevar response struct {Error string `json:"error,omitempty"`}if err := json.Unmarshal(responseBytes, &response); err != nil {return err}if response.Error != "" {return errors.New(response.Error)}return nil}// ConfigHas calls the config_has host function.func ConfigHas(key string) (bool, error) {// Marshal request to JSONreq := configHasRequest{Key: key,}reqBytes, err := json.Marshal(req)if err != nil {return false, err}reqMem := pdk.AllocateBytes(reqBytes)defer reqMem.Free()// Call the host functionresponsePtr := config_has(reqMem.Offset())// Read the response from memoryresponseMem := pdk.FindMemory(responsePtr)responseBytes := responseMem.ReadBytes()// Parse the responsevar response configHasResponseif err := json.Unmarshal(responseBytes, &response); err != nil {return false, err}// Convert Error field to Go errorif response.Error != "" {return false, errors.New(response.Error)}return response.Exists, nil}