46 lines
1 KiB
Rust
46 lines
1 KiB
Rust
|
|
// Code generated by ndpgen. DO NOT EDIT.
|
||
|
|
//
|
||
|
|
// This file contains client wrappers for the Counter 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 CounterCountRequest {
|
||
|
|
name: String,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Deserialize)]
|
||
|
|
#[serde(rename_all = "camelCase")]
|
||
|
|
struct CounterCountResponse {
|
||
|
|
#[serde(default)]
|
||
|
|
value: i32,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[host_fn]
|
||
|
|
extern "ExtismHost" {
|
||
|
|
fn counter_count(input: Json<CounterCountRequest>) -> Json<CounterCountResponse>;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Calls the counter_count host function.
|
||
|
|
///
|
||
|
|
/// # Arguments
|
||
|
|
/// * `name` - String parameter.
|
||
|
|
///
|
||
|
|
/// # Returns
|
||
|
|
/// The value value.
|
||
|
|
///
|
||
|
|
/// # Errors
|
||
|
|
/// Returns an error if the host function call fails.
|
||
|
|
pub fn count(name: &str) -> Result<i32, Error> {
|
||
|
|
let response = unsafe {
|
||
|
|
counter_count(Json(CounterCountRequest {
|
||
|
|
name: name.to_owned(),
|
||
|
|
}))?
|
||
|
|
};
|
||
|
|
|
||
|
|
Ok(response.0.value)
|
||
|
|
}
|