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

ambee/giterated

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

Wow!

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨6530104

⁨plugins/example-plugin/src/main.rs⁩ - ⁨1453⁩ 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::state::RuntimeState;
9 use giterated_plugin::abi::vtable::runtime::RuntimeHandle;
10 use giterated_runtime::{Runtime, StaticRuntimeExt};
11 use tracing::{info, Level};
12
13 #[tokio::main]
14 async fn main() -> Result<(), anyhow::Error> {
15 tracing_subscriber::fmt()
16 .pretty()
17 .with_thread_names(true)
18 .with_max_level(Level::TRACE)
19 .init();
20
21 let mut runtime = Runtime::new();
22
23 runtime.load_dylib("example_plugin_dylib.dll")?;
24
25 runtime.init();
26
27 let runtime = unsafe { RuntimeHandle::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