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/main.rs⁩ - ⁨1405⁩ 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::abi::vtable::runtime::RuntimeHandle;
9 use giterated_runtime::{Runtime, StaticRuntimeExt};
10 use tracing::{info, Level};
11
12 #[tokio::main]
13 async fn main() -> Result<(), anyhow::Error> {
14 tracing_subscriber::fmt()
15 .pretty()
16 .with_thread_names(true)
17 .with_max_level(Level::TRACE)
18 .init();
19
20 let mut runtime = Runtime::new();
21
22 runtime.load_dylib("example_plugin_dylib.dll")?;
23
24 runtime.init();
25
26 let runtime = unsafe { RuntimeHandle::from_static() };
27
28 let _object_request = ObjectRequest(String::from("foobar"));
29
30 let _state = OperationState::default();
31
32 let _instance = runtime
33 .get_object::<Instance>("giterated.dev", &OperationState::default())
34 .await?;
35
36 let mut user = runtime
37 .get_object::<User>("ambee:giterated.dev", &OperationState::default())
38 .await?;
39
40 let display_name = user.get::<DisplayName>(&OperationState::default()).await?;
41
42 info!("Display name for user as a value: {}", display_name);
43
44 let display_name = user
45 .get_setting::<DisplayName>(&OperationState::default())
46 .await?;
47
48 info!("Display name for user as a setting: {}", display_name);
49
50 Ok(())
51 }
52