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

ambee/giterated

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

no clue what this is

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨7889bf6

⁨plugins/example-plugin/src/main.rs⁩ - ⁨1622⁩ 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::domain::runtime_domain_state;
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 = RuntimeHandle::from_static();
28
29 let _object_request = ObjectRequest(String::from("foobar"));
30
31 let mut state = giterated_plugin::abi::state::State::default();
32
33 let mut state_manager =
34 unsafe { giterated_plugin::abi::state::StateManager::new_mut(&mut state) };
35 unsafe { state_manager.write_state(unsafe { runtime_domain_state() }) };
36
37 println!("state info: {:#?}", state);
38
39 let _instance = runtime
40 .get_object::<Instance>("giterated.dev", &mut state)
41 .await?;
42
43 let mut user = runtime
44 .get_object::<User>("ambee:giterated.dev", &mut state)
45 .await?;
46
47 let display_name = user.get::<DisplayName>(&mut state).await?;
48
49 info!("Display name for user as a value: {}", display_name);
50
51 let display_name = user.get_setting::<DisplayName>(&mut state).await?;
52
53 info!("Display name for user as a setting: {}", display_name);
54
55 Ok(())
56 }
57