🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
// 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<nd_pdk_types::SongRef>,
opts: MatchOptions,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
struct MatcherMatchSongsResponse {
#[serde(default)]
results: Vec<Option<nd_pdk_types::Track>>,
#[serde(default)]
error: Option<String>,
}
#[host_fn]
extern "ExtismHost" {
fn matcher_matchsongs(input: Json<MatcherMatchSongsRequest>) -> Json<MatcherMatchSongsResponse>;
}
/// 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<nd_pdk_types::SongRef> parameter.
/// * `opts` - MatchOptions parameter.
///
/// # Returns
/// The results value.
///
/// # Errors
/// Returns an error if the host function call fails.
pub fn match_songs(songs: Vec<nd_pdk_types::SongRef>, opts: MatchOptions) -> Result<Vec<Option<nd_pdk_types::Track>>, 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)
}