// Code generated by hostgen. DO NOT EDIT. // // This file contains client wrappers for the SubsonicAPI host service. // It is intended for use in Navidrome plugins built with TinyGo. package main import ( "encoding/json" "github.com/extism/go-pdk" ) // subsonicapi_call is the host function provided by Navidrome. // //go:wasmimport extism:host/user subsonicapi_call func subsonicapi_call(uint64) uint64 // SubsonicAPICallResponse is the response type for SubsonicAPI.Call. type SubsonicAPICallResponse struct { ResponseJSON string `json:"responseJSON,omitempty"` Error string `json:"error,omitempty"` } // SubsonicAPICall calls the subsonicapi_call host function. // Call executes a Subsonic API request and returns the JSON response. // // The uri parameter should be the Subsonic API path without the server prefix, // e.g., "getAlbumList2?type=random&size=10". The response is returned as raw JSON. func SubsonicAPICall(uri string) (*SubsonicAPICallResponse, error) { uriMem := pdk.AllocateString(uri) defer uriMem.Free() // Call the host function responsePtr := subsonicapi_call(uriMem.Offset()) // Read the response from memory responseMem := pdk.FindMemory(responsePtr) responseBytes := responseMem.ReadBytes() // Parse the response var response SubsonicAPICallResponse if err := json.Unmarshal(responseBytes, &response); err != nil { return nil, err } return &response, nil }