mirror of
https://github.com/navidrome/navidrome.git
synced 2026-01-03 06:15:22 +00:00
52 lines
1.1 KiB
Rust
52 lines
1.1 KiB
Rust
// Code generated by ndpgen. DO NOT EDIT.
|
|
//
|
|
// This file contains client wrappers for the Codec host service.
|
|
// It is intended for use in Navidrome plugins built with extism-pdk.
|
|
|
|
use extism_pdk::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
struct CodecEncodeRequest {
|
|
data: Vec<u8>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
struct CodecEncodeResponse {
|
|
#[serde(default)]
|
|
result: Vec<u8>,
|
|
#[serde(default)]
|
|
error: Option<String>,
|
|
}
|
|
|
|
#[host_fn]
|
|
extern "ExtismHost" {
|
|
fn codec_encode(input: Json<CodecEncodeRequest>) -> Json<CodecEncodeResponse>;
|
|
}
|
|
|
|
/// Calls the codec_encode host function.
|
|
///
|
|
/// # Arguments
|
|
/// * `data` - Vec<u8> parameter.
|
|
///
|
|
/// # Returns
|
|
/// The result value.
|
|
///
|
|
/// # Errors
|
|
/// Returns an error if the host function call fails.
|
|
pub fn encode(data: Vec<u8>) -> Result<Vec<u8>, Error> {
|
|
let response = unsafe {
|
|
codec_encode(Json(CodecEncodeRequest {
|
|
data: data,
|
|
}))?
|
|
};
|
|
|
|
if let Some(err) = response.0.error {
|
|
return Err(Error::msg(err));
|
|
}
|
|
|
|
Ok(response.0.result)
|
|
}
|