JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Spinning

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨1788060

⁨plugins/example-plugin/src/lib.rs⁩ - ⁨1455⁩ bytes
Raw
1 use anyhow::Error;
2 use giterated_models::{
3 error::OperationError,
4 instance::Instance,
5 object::{ObjectRequest, ObjectRequestError, ObjectResponse},
6 user::{DisplayName, User},
7 };
8 use giterated_plugin::{abi::state::StateUUID, local::PluginStackBuilder, plugin};
9
10 plugin!(
11 name: "Example Plugin",
12 version: "0.0.1",
13 author: "Amber Kowalski",
14 // Experimental syntax for requesting specific plugin features
15 features: ["tracing", "tokio"],
16 description: "An example plugin to demonstrate the development process of Giterated plugins."
17 );
18
19 /// Some kind of global state for the plugin
20 struct PluginState;
21
22 impl StateUUID for PluginState {
23 fn uuid() -> u128 {
24 214829528589663836760123667646253464473
25 }
26 }
27
28 /// The plugin's initialization function. Ran when the plugin is loaded, used to
29 /// build the plugin's stack.
30 #[plugin::init]
31 pub fn init(builder: &mut PluginStackBuilder) -> Result<(), Error> {
32 builder.insert_state(PluginState);
33 builder.object::<Instance>().object::<User>();
34 builder.setting_getter(setting_getter);
35
36 Ok(())
37 }
38
39 async fn handler(
40 object: User,
41 operation: ObjectRequest,
42 // state_extractor: StateExtractor<PluginState>,
43 ) -> Result<ObjectResponse, OperationError<ObjectRequestError>> {
44 todo!()
45 }
46
47 async fn setting_getter(
48 object: User,
49 // state_extractor: StateExtractor<PluginState>,
50 ) -> Result<DisplayName, OperationError<Error>> {
51 todo!()
52 }
53