// Code generated by ndpgen. DO NOT EDIT.
//
// This file contains client wrappers for the Ping host service.
// It is intended for use in Navidrome plugins built with extism-pdk.

use extism_pdk::*;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
struct PingPingResponse {
    #[serde(default)]
    error: Option<String>,
}

#[host_fn]
extern "ExtismHost" {
    fn ping_ping(input: Json<serde_json::Value>) -> Json<PingPingResponse>;
}

/// Calls the ping_ping host function.
///
/// # Errors
/// Returns an error if the host function call fails.
pub fn ping() -> Result<(), Error> {
    let response = unsafe {
        ping_ping(Json(serde_json::json!({})))?
    };

    if let Some(err) = response.0.error {
        return Err(Error::msg(err));
    }

    Ok(())
}
