// Code generated by ndpgen. DO NOT EDIT. // // This file contains client wrappers for the Matcher host service. // It is intended for use in Navidrome plugins built with extism-pdk. use extism_pdk::*; use serde::{Deserialize, Serialize}; /// MatchOptions carries optional parameters for a match request. #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct MatchOptions { #[serde(default)] pub username: String, } #[derive(Debug, Clone, Serialize)] #[serde(rename_all = "camelCase")] struct MatcherMatchSongsRequest { songs: Vec, opts: MatchOptions, } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] struct MatcherMatchSongsResponse { #[serde(default)] results: Vec>, #[serde(default)] error: Option, } #[host_fn] extern "ExtismHost" { fn matcher_matchsongs(input: Json) -> Json; } /// MatchSongs resolves each input song to its best-matching library track. /// It returns one entry per input song, in the same order as the input; the /// entry for an input song that had no match is empty (absent). Results are /// limited to the libraries the plugin (and the scoped user, if any) can access. /// /// # Arguments /// * `songs` - Vec parameter. /// * `opts` - MatchOptions parameter. /// /// # Returns /// The results value. /// /// # Errors /// Returns an error if the host function call fails. pub fn match_songs(songs: Vec, opts: MatchOptions) -> Result>, Error> { let response = unsafe { matcher_matchsongs(Json(MatcherMatchSongsRequest { songs: songs, opts: opts, }))? }; if let Some(err) = response.0.error { return Err(Error::msg(err)); } Ok(response.0.results) }