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

ambee/giterated

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

More progress :)

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨92c3f32

⁨plugins/example-plugin/src/main.rs⁩ - ⁨1446⁩ bytes
Raw
1 use giterated_models::object_backend::ObjectBackend;
2 use giterated_models::{
3 instance::Instance,
4 object::ObjectRequest,
5 operation::OperationState,
6 user::{DisplayName, User},
7 };
8 use giterated_plugin::{callback::RuntimeState, handle::PluginHandle, new_stack::Runtime};
9 use tracing::{info, Level};
10
11 #[tokio::main]
12 async fn main() -> Result<(), anyhow::Error> {
13 tracing_subscriber::fmt()
14 .pretty()
15 .with_thread_names(true)
16 .with_max_level(Level::TRACE)
17 .init();
18
19 let handle = PluginHandle::from_dylib("example_plugin_dylib.dll").unwrap();
20
21 let mut runtime = Runtime::new();
22
23 runtime.insert_plugin(handle);
24
25 runtime.init();
26
27 let runtime = unsafe { RuntimeState::from_static() };
28
29 let _object_request = ObjectRequest(String::from("foobar"));
30
31 let _state = OperationState::default();
32
33 let _instance = runtime
34 .get_object::<Instance>("giterated.dev", &OperationState::default())
35 .await?;
36
37 let mut user = runtime
38 .get_object::<User>("ambee:giterated.dev", &OperationState::default())
39 .await?;
40
41 let display_name = user.get::<DisplayName>(&OperationState::default()).await?;
42
43 info!("Display name for user as a value: {}", display_name);
44
45 let display_name = user
46 .get_setting::<DisplayName>(&OperationState::default())
47 .await?;
48
49 info!("Display name for user as a setting: {}", display_name);
50
51 Ok(())
52 }
53