use std::{fmt::Debug, marker::PhantomData}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::Value; use crate::{error::GetValueError, object::GiteratedObject, operation::GiteratedOperation}; pub trait GiteratedObjectValue: Send + Sync + Serialize + DeserializeOwned { type Object: GiteratedObject; fn value_name() -> &'static str; } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct GetValue { pub value_name: String, } impl GiteratedOperation for GetValue { fn operation_name() -> &'static str { "get_value" } type Success = Value; type Failure = GetValueError; } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct GetValueTyped { pub value_name: String, pub ty: PhantomData, } impl> GiteratedOperation for GetValueTyped { fn operation_name() -> &'static str { "get_value" } type Success = V; type Failure = GetValueError; } #[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(), } } pub fn into_inner(self) -> Value { self.value } } impl GiteratedObjectValue for AnyValue { type Object = O; fn value_name() -> &'static str { todo!() } }