use abi_stable::{
declare_root_module_statics,
library::RootModule,
package_version_strings,
sabi_types::VersionStrings,
std_types::{ROption, RString, RVec},
StableAbi,
};
#[repr(C)]
#[derive(StableAbi)]
#[sabi(kind(Prefix(prefix_ref = PluginRef)))]
#[sabi(missing_field(panic))]
pub struct Plugin {
pub init: extern "C" fn(RString),
pub info: extern "C" fn() -> PluginInfo,
pub get_matches: extern "C" fn(RString) -> u64,
pub poll_matches: extern "C" fn(u64) -> PollResult,
pub handle_selection: extern "C" fn(Match) -> HandleResult,
}
#[repr(C)]
#[derive(StableAbi, Debug)]
pub struct PluginInfo {
pub name: RString,
pub icon: RString,
}
#[repr(C)]
#[derive(StableAbi, Clone)]
pub struct Match {
pub title: RString,
pub description: ROption<RString>,
pub use_pango: bool,
pub icon: ROption<RString>,
pub id: ROption<u64>,
}
#[repr(C)]
#[derive(StableAbi)]
pub enum HandleResult {
Close,
Refresh(bool),
Copy(RVec<u8>),
Stdout(RVec<u8>),
}
#[repr(C)]
#[derive(StableAbi)]
pub enum PollResult {
Ready(RVec<Match>),
Pending,
Cancelled,
}
impl RootModule for PluginRef {
declare_root_module_statics! {PluginRef}
const BASE_NAME: &'static str = "anyrun_plugin";
const NAME: &'static str = "anyrun_plugin";
const VERSION_STRINGS: VersionStrings = package_version_strings!();
}