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

ambee/giterated

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

Fixed imports!

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨ef0e853

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