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

ambee/giterated

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

Beginning of `stack-next` refactor

-Refactoring the protocol stack into something similar to a runtime. -Handles merging handler builders which is placing the ground work for plugins in. - Increased metadata generation during compilation enables less ser/de during execution. - Goal is to have an O(1) time from incoming operation to calling handlers. - Decreased penalty for using the statically typed API from within your code, now avoids some allocation. # Changes - Added `GiteratedRuntime` which is to replace the current unified stack - Added `RuntimeBuilder` which does what the current `OperationHandlers` struct does, but much better. - Added `RuntimeMetadata` to store type metadata for new `Any` based internals - Refactored serde_json out of the internal operation handling

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨708dea4

⁨giterated-models/src/settings/operations.rs⁩ - ⁨1043⁩ bytes
Raw
1 use std::{fmt::Debug, marker::PhantomData};
2
3 use serde::{de::DeserializeOwned, Deserialize, Serialize};
4 use serde_json::Value;
5 use thiserror::Error;
6
7 use crate::{object::GiteratedObject, operation::GiteratedOperation};
8
9 use super::{AnySetting, Setting};
10
11 #[derive(Serialize, Deserialize, Debug, Clone)]
12 pub struct GetSetting {
13 pub setting_name: String,
14 }
15
16 impl<O: GiteratedObject> GiteratedOperation<O> for GetSetting {
17 fn operation_name() -> &'static str {
18 "get_setting"
19 }
20
21 type Success = Value;
22
23 type Failure = GetSettingError;
24 }
25
26 #[derive(Error, Debug, Serialize, Deserialize)]
27 pub enum GetSettingError {}
28 #[derive(Serialize, Deserialize, Debug, Clone)]
29 pub struct SetSetting {
30 pub setting_name: String,
31 pub value: AnySetting,
32 }
33
34 impl<O: GiteratedObject> GiteratedOperation<O> for SetSetting {
35 fn operation_name() -> &'static str {
36 "set_setting"
37 }
38
39 type Success = ();
40
41 type Failure = SetSettingError;
42 }
43
44 #[derive(Error, Debug, Serialize, Deserialize)]
45 pub enum SetSettingError {}
46