#[cfg(feature = "host")]
use nitro_shared::output::NitroOutput;
use serde::{Serialize, de::DeserializeOwned};
#[cfg(feature = "host")]
use crate::hook::call::{HookCallArg, HookHandle};
#[cfg(feature = "host")]
pub mod call;
#[cfg(feature = "host")]
pub mod executable;
pub mod hooks;
#[cfg(feature = "host")]
pub mod wasm;
pub trait Hook {
type Arg: Serialize + DeserializeOwned + Send + 'static;
type Result: DeserializeOwned + Serialize + Default + Send + 'static;
fn get_name(&self) -> &'static str {
Self::get_name_static()
}
fn get_name_static() -> &'static str;
fn get_takes_over() -> bool {
false
}
fn is_asynchronous() -> bool {
false
}
fn get_version() -> u16;
#[cfg(feature = "host")]
#[allow(async_fn_in_trait)]
async fn call(
&self,
arg: HookCallArg<'_, Self>,
o: &mut impl NitroOutput,
) -> anyhow::Result<HookHandle<Self>>
where
Self: Sized,
{
crate::hook::executable::call_executable(self, arg, o).await
}
}
pub static PLUGIN_DIR_TOKEN: &str = "${PLUGIN_DIR}";
pub static EXE_EXTENSION_TOKEN: &str = "${EXE_EXTENSION}";
pub static CUSTOM_CONFIG_ENV: &str = "NITRO_CUSTOM_CONFIG";
pub static DATA_DIR_ENV: &str = "NITRO_DATA_DIR";
pub static CONFIG_DIR_ENV: &str = "NITRO_CONFIG_DIR";
pub static PLUGIN_STATE_ENV: &str = "NITRO_PLUGIN_STATE";
pub static NITRO_VERSION_ENV: &str = "NITRO_VERSION";
pub static NITRO_PLUGIN_ENV: &str = "NITRO_PLUGIN";
pub static HOOK_VERSION_ENV: &str = "NITRO_HOOK_VERSION";
pub static PLUGIN_LIST_ENV: &str = "NITRO_PLUGIN_LIST";
pub static INSTANCE_LIST_ENV: &str = "NITRO_INSTANCES";
pub static TEMPLATE_LIST_ENV: &str = "NITRO_TEMPLATES";
pub static WASM_FILE_NAME: &str = "plugin.wasm";