From 90ecba82616c54e0ff632d3de3c88e0304f9f9e3 Mon Sep 17 00:00:00 2001 From: Kirottu Date: Mon, 1 May 2023 11:19:12 +0300 Subject: [PATCH] Fixed plugin example in README --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3544757..e5a3d5f 100644 --- a/README.md +++ b/README.md @@ -208,13 +208,15 @@ abi_stable = "0.11.1" ```rs use abi_stable::std_types::{RString, RVec, ROption}; -use anyrun_plugin::{plugin, PluginInfo, Match, HandleResult}; +use anyrun_plugin::*; +#[init] fn init(config_dir: RString) { // Your initialization code. This is run in another thread. // The return type is the data you want to share between functions } +#[info] fn info() -> PluginInfo { PluginInfo { name: "Demo".into(), @@ -222,7 +224,8 @@ fn info() -> PluginInfo { } } -fn get_matches(input: RString, data: &mut ()) -> RVec { +#[get_matches] +fn get_matches(input: RString) -> RVec { // The logic to get matches from the input text in the `input` argument. // The `data` is a mutable reference to the shared data type later specified. vec![Match { @@ -234,13 +237,11 @@ fn get_matches(input: RString, data: &mut ()) -> RVec { }].into() } -fn handler(selection: Match, input: RString, data: &mut ()) -> HandleResult { +#[handler] +fn handler(selection: Match) -> HandleResult { // Handle the selected match and return how anyrun should proceed HandleResult::Close } - -// The type of the data we want to store is the last one, we don't need it in this one so it can be the unit type. -plugin!(init, info, get_matches, handler, ()); ``` And that's it! That's all of the API needed to make runners. Refer to the plugins in the [plugins](plugins) folder for more examples.