// Code generated by ndpgen. 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 wasip1package hostimport ("encoding/json""errors""github.com/navidrome/navidrome/plugins/pdk/go/pdk")// User represents the User data structure.// User represents a Navidrome user with minimal information exposed to plugins.// Sensitive fields like password, email, and internal IDs are intentionally excluded.type User struct {UserName string `json:"userName"`Name string `json:"name"`IsAdmin bool `json:"isAdmin"`}// users_getusers is the host function provided by Navidrome.////go:wasmimport extism:host/user users_getusersfunc users_getusers(uint64) uint64// users_getadmins is the host function provided by Navidrome.////go:wasmimport extism:host/user users_getadminsfunc users_getadmins(uint64) uint64type usersGetUsersResponse struct {Result []User `json:"result,omitempty"`Error string `json:"error,omitempty"`}type usersGetAdminsResponse struct {Result []User `json:"result,omitempty"`Error string `json:"error,omitempty"`}// UsersGetUsers calls the users_getusers host function.// GetUsers returns all users the plugin has been granted access to.// Only minimal user information (userName, name, isAdmin) is returned.// Sensitive fields like password and email are never exposed.//// Returns a slice of users the plugin can access, or an empty slice if none configured.func UsersGetUsers() ([]User, error) {// No parameters - allocate empty JSON objectreqMem := pdk.AllocateBytes([]byte("{}"))defer reqMem.Free()// Call the host functionresponsePtr := users_getusers(reqMem.Offset())// Read the response from memoryresponseMem := pdk.FindMemory(responsePtr)responseBytes := responseMem.ReadBytes()// Parse the responsevar response usersGetUsersResponseif err := json.Unmarshal(responseBytes, &response); err != nil {return nil, err}// Convert Error field to Go errorif response.Error != "" {return nil, errors.New(response.Error)}return response.Result, nil}// UsersGetAdmins calls the users_getadmins host function.// GetAdmins returns only admin users the plugin has been granted access to.// This is a convenience method that filters GetUsers results to include only admins.//// Returns a slice of admin users the plugin can access, or an empty slice if none.func UsersGetAdmins() ([]User, error) {// No parameters - allocate empty JSON objectreqMem := pdk.AllocateBytes([]byte("{}"))defer reqMem.Free()// Call the host functionresponsePtr := users_getadmins(reqMem.Offset())// Read the response from memoryresponseMem := pdk.FindMemory(responsePtr)responseBytes := responseMem.ReadBytes()// Parse the responsevar response usersGetAdminsResponseif err := json.Unmarshal(responseBytes, &response); err != nil {return nil, err}// Convert Error field to Go errorif response.Error != "" {return nil, errors.New(response.Error)}return response.Result, nil}