use std::{fmt::Debug, marker::PhantomData}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::Value; use thiserror::Error; use crate::{ model::settings::Setting, operation::{GiteratedObject, GiteratedObjectValue, GiteratedOperation}, }; pub mod instance; pub mod repository; pub mod user; // #[derive(Serialize, Deserialize)] // pub struct GetRequest { // value_name: String, // _marker: PhantomData, // } // impl + Send> GiteratedOperation // for GetRequest // { // type Success = V; // type Failure = GetValueError; // } // #[derive(Error, Debug, Serialize, Deserialize)] // pub enum GetValueError {} #[derive(Serialize, Deserialize, Debug, Clone)] pub struct GetSetting { pub setting_name: String, pub _marker: PhantomData, } impl GiteratedOperation for GetSetting { fn operation_name() -> &'static str { "get_setting" } type Success = S; type Failure = GetSettingError; } #[derive(Error, Debug, Serialize, Deserialize)] pub enum GetSettingError {} #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(bound(deserialize = "S: Setting"))] pub struct SetSetting { pub setting_name: String, pub value: S, } impl GiteratedOperation for SetSetting { fn operation_name() -> &'static str { "set_setting" } type Success = (); type Failure = SetSettingError; } #[derive(Error, Debug, Serialize, Deserialize)] pub enum SetSettingError {} #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(transparent)] pub struct AnyValue { value: Value, #[serde(skip)] _marker: PhantomData, } impl AnyValue { pub unsafe fn from_raw(value: Value) -> Self { Self { value, _marker: Default::default(), } } } impl GiteratedObjectValue for AnyValue { type Object = O; fn value_name() -> &'static str { todo!() } }