🏡 index : quine-global/quintodrome.git

// Code generated by ndpgen. DO NOT EDIT.
//
// This file contains client wrappers for the Storage host service.
// It is intended for use in Navidrome plugins built with TinyGo.
//
//go:build wasip1

package host

import (
	"encoding/json"

	"github.com/navidrome/navidrome/plugins/pdk/go/pdk"
)

// storage_getstoragepath is the host function provided by Navidrome.
//
//go:wasmimport extism:host/user storage_getstoragepath
func storage_getstoragepath(uint64) uint64

type storageGetStoragePathResponse struct {
	Result string `json:"result,omitempty"`
}

// StorageGetStoragePath calls the storage_getstoragepath host function.
// GetStoragePath retrieves the persistent storage path, if allowed
func StorageGetStoragePath() string {
	// No parameters - allocate empty JSON object
	reqMem := pdk.AllocateBytes([]byte("{}"))
	defer reqMem.Free()

	// Call the host function
	responsePtr := storage_getstoragepath(reqMem.Offset())

	// Read the response from memory
	responseMem := pdk.FindMemory(responsePtr)
	responseBytes := responseMem.ReadBytes()

	// Parse the response
	var response storageGetStoragePathResponse
	if err := json.Unmarshal(responseBytes, &response); err != nil {
		return ""
	}

	return response.Result
}