navidrome/plugins/cmd/hostgen/testdata/search_client_expected.go
2025-12-31 17:06:29 -05:00

48 lines
1.2 KiB
Go

// Code generated by hostgen. 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 wasip1
package main
import (
"encoding/json"
"github.com/extism/go-pdk"
)
// search_find is the host function provided by Navidrome.
//
//go:wasmimport extism:host/user search_find
func search_find(uint64) uint64
// SearchFindResponse is the response type for Search.Find.
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) (*SearchFindResponse, error) {
queryMem := pdk.AllocateString(query)
defer queryMem.Free()
// Call the host function
responsePtr := search_find(queryMem.Offset())
// Read the response from memory
responseMem := pdk.FindMemory(responsePtr)
responseBytes := responseMem.ReadBytes()
// Parse the response
var response SearchFindResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return nil, err
}
return &response, nil
}