mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-28 16:25:10 +00:00
50 lines
1.1 KiB
Rust
50 lines
1.1 KiB
Rust
// Code generated by ndpgen. DO NOT EDIT.
|
|
//
|
|
// This file contains client wrappers for the Echo 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 EchoEchoRequest {
|
|
message: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
struct EchoEchoResponse {
|
|
#[serde(default)]
|
|
reply: String,
|
|
#[serde(default)]
|
|
error: Option<String>,
|
|
}
|
|
|
|
#[link(wasm_import_module = "extism:host/user")]
|
|
extern "C" {
|
|
fn echo_echo(input: u64) -> u64;
|
|
}
|
|
|
|
/// Calls the echo_echo host function.
|
|
///
|
|
/// # Arguments
|
|
/// * `message` - String parameter.
|
|
///
|
|
/// # Returns
|
|
/// The reply value.
|
|
///
|
|
/// # Errors
|
|
/// Returns an error if the host function call fails.
|
|
pub fn echo(message: &str) -> Result<String, Error> {
|
|
let response: EchoEchoResponse = unsafe { nd_pdk_types::hostcall::call(echo_echo, &EchoEchoRequest {
|
|
message: message.to_owned(),
|
|
}) }?;
|
|
|
|
if let Some(err) = response.error {
|
|
return Err(Error::msg(err));
|
|
}
|
|
|
|
Ok(response.reply)
|
|
}
|