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

ambee/giterated

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

Structure refactoring

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨a8f41ac

⁨giterated-core/src/lib.rs⁩ - ⁨1808⁩ bytes
Raw
1 mod callback;
2 mod state;
3 mod types;
4
5 #[derive(Clone)]
6 #[repr(C)]
7 pub struct RuntimeState {
8 pub vtable: VTable<RuntimeState>,
9 }
10
11 impl RuntimeState {
12 pub unsafe fn from_static() -> Self {
13 let runtime = giterated_static_runtime::get_runtime_reference();
14
15 let runtime = runtime.cast::<Box<Runtime>>().as_ref();
16
17 runtime.state()
18 }
19
20 pub unsafe fn runtime_state() -> PluginState {
21 let runtime = giterated_static_runtime::get_runtime_reference();
22
23 PluginState::from_raw_ptr(giterated_static_runtime::get_runtime_reference().as_ptr())
24 }
25 }
26
27 #[async_trait::async_trait(?Send)]
28 impl ObjectBackend for RuntimeState {
29 async fn object_operation<O, D>(
30 &self,
31 object: O,
32 _operation: &str,
33 payload: D,
34 _operation_state: &OperationState,
35 ) -> Result<D::Success, OperationError<D::Failure>>
36 where
37 O: GiteratedObject + Debug + 'static,
38 D: GiteratedOperation<O> + Debug + 'static,
39 D::Success: Clone,
40 D::Failure: Clone,
41 {
42 // let _object = AnyObject::new(object);
43 // let _operation = AnyOperation::new(payload);
44
45 todo!()
46 }
47
48 async fn get_object<O: GiteratedObject + Debug + 'static>(
49 &self,
50 object_str: &str,
51 operation_state: &OperationState,
52 ) -> Result<Object<O, Self>, OperationError<ObjectRequestError>> {
53 // let object = unsafe {
54 // (self.vtable.get_object)(
55 // Self::runtime_state(),
56 // object_str,
57 // &mut operation_state.clone(),
58 // )
59 // }?;
60
61 // let object = unsafe { object.cast::<O>() };
62
63 panic!("object casted");
64
65 // Ok(unsafe { Object::new_unchecked(object, self.clone()) })
66
67 todo!()
68 }
69 }
70