// 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 extism-pdk. use extism_pdk::*; use serde::{Deserialize, Serialize}; /// User represents a Navidrome user with minimal information exposed to plugins. /// Sensitive fields like password, email, and internal IDs are intentionally excluded. #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct User { pub user_name: String, pub name: String, pub is_admin: bool, } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] struct UsersGetUsersResponse { #[serde(default)] result: Vec, #[serde(default)] error: Option, } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] struct UsersGetAdminsResponse { #[serde(default)] result: Vec, #[serde(default)] error: Option, } #[host_fn] extern "ExtismHost" { fn users_getusers(input: Json) -> Json; fn users_getadmins(input: Json) -> Json; } /// 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. /// /// # Returns /// The result value. /// /// # Errors /// Returns an error if the host function call fails. pub fn get_users() -> Result, Error> { let response = unsafe { users_getusers(Json(serde_json::json!({})))? }; if let Some(err) = response.0.error { return Err(Error::msg(err)); } Ok(response.0.result) } /// 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. /// /// # Returns /// The result value. /// /// # Errors /// Returns an error if the host function call fails. pub fn get_admins() -> Result, Error> { let response = unsafe { users_getadmins(Json(serde_json::json!({})))? }; if let Some(err) = response.0.error { return Err(Error::msg(err)); } Ok(response.0.result) }