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

⁨giterated-core/src/lib.rs⁩ - ⁨3277⁩ bytes
Raw
1 use giterated_abi::{
2 state::{State, StateUUID},
3 vtable::{runtime::RuntimeHandle, VTable},
4 };
5 use giterated_models::{
6 error::OperationError,
7 object::{GiteratedObject, Object, ObjectRequestError},
8 object_backend::ObjectBackend,
9 operation::{GiteratedOperation, OperationState},
10 };
11 use std::fmt::Debug;
12 use types::TypeMetadata;
13
14 pub mod types;
15
16 #[derive(Clone)]
17 #[repr(C)]
18 pub struct RuntimeState {
19 pub vtable: &'static VTable<RuntimeHandle>,
20 }
21
22 #[async_trait::async_trait(?Send)]
23 impl ObjectBackend<State> for RuntimeState {
24 async fn object_operation<O, D>(
25 &self,
26 object: O,
27 operation: &str,
28 payload: D,
29 operation_state: &mut State,
30 ) -> Result<D::Success, OperationError<D::Failure>>
31 where
32 O: GiteratedObject + Debug + 'static,
33 D: GiteratedOperation<O> + Debug + 'static,
34 D::Success: Clone,
35 D::Failure: Clone,
36 {
37 todo!()
38 }
39
40 async fn get_object<O: GiteratedObject + Debug + 'static>(
41 &self,
42 object_str: &str,
43 operation_state: &mut State,
44 ) -> Result<Object<O, Self, State>, OperationError<ObjectRequestError>> {
45 todo!()
46 }
47 }
48
49 // impl RuntimeState {
50 // pub unsafe fn from_static() -> Self {
51 // let runtime = giterated_static_runtime::get_runtime_reference();
52
53 // let runtime = runtime.cast::<Box<Runtime>>().as_ref();
54
55 // runtime.state()
56 // }
57
58 // pub unsafe fn runtime_state() -> PluginState {
59 // let runtime = giterated_static_runtime::get_runtime_reference();
60
61 // PluginState::from_raw_ptr(giterated_static_runtime::get_runtime_reference().as_ptr())
62 // }
63 // }
64
65 // #[async_trait::async_trait(?Send)]
66 // impl ObjectBackend for RuntimeState {
67 // async fn object_operation<O, D>(
68 // &self,
69 // object: O,
70 // _operation: &str,
71 // payload: D,
72 // _operation_state: &OperationState,
73 // ) -> Result<D::Success, OperationError<D::Failure>>
74 // where
75 // O: GiteratedObject + Debug + 'static,
76 // D: GiteratedOperation<O> + Debug + 'static,
77 // D::Success: Clone,
78 // D::Failure: Clone,
79 // {
80 // // let _object = AnyObject::new(object);
81 // // let _operation = AnyOperation::new(payload);
82
83 // todo!()
84 // }
85
86 // async fn get_object<O: GiteratedObject + Debug + 'static>(
87 // &self,
88 // object_str: &str,
89 // operation_state: &OperationState,
90 // ) -> Result<Object<O, Self>, OperationError<ObjectRequestError>> {
91 // // let object = unsafe {
92 // // (self.vtable.get_object)(
93 // // Self::runtime_state(),
94 // // object_str,
95 // // &mut operation_state.clone(),
96 // // )
97 // // }?;
98
99 // // let object = unsafe { object.cast::<O>() };
100
101 // panic!("object casted");
102
103 // // Ok(unsafe { Object::new_unchecked(object, self.clone()) })
104
105 // todo!()
106 // }
107 // }
108
109 pub struct DomainMetadata(pub &'static TypeMetadata);
110
111 impl DomainMetadata {
112 pub fn from_static() -> Self {
113 DomainMetadata(unsafe { TypeMetadata::from_static() })
114 }
115 }
116
117 impl StateUUID for DomainMetadata {
118 fn uuid() -> u128 {
119 1
120 }
121 }
122