mirror of
https://github.com/navidrome/navidrome.git
synced 2026-02-02 06:24:14 +00:00
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
// Code generated by hostgen. 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 wasip1
|
|
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/extism/go-pdk"
|
|
)
|
|
|
|
// users_get is the host function provided by Navidrome.
|
|
//
|
|
//go:wasmimport extism:host/user users_get
|
|
func users_get(uint64, uint64) uint64
|
|
|
|
// UsersGetResponse is the response type for Users.Get.
|
|
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) (*UsersGetResponse, error) {
|
|
idBytes, err := json.Marshal(id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
idMem := pdk.AllocateBytes(idBytes)
|
|
defer idMem.Free()
|
|
filterBytes, err := json.Marshal(filter)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
filterMem := pdk.AllocateBytes(filterBytes)
|
|
defer filterMem.Free()
|
|
|
|
// Call the host function
|
|
responsePtr := users_get(idMem.Offset(), filterMem.Offset())
|
|
|
|
// Read the response from memory
|
|
responseMem := pdk.FindMemory(responsePtr)
|
|
responseBytes := responseMem.ReadBytes()
|
|
|
|
// Parse the response
|
|
var response UsersGetResponse
|
|
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &response, nil
|
|
}
|