use std::{fmt::Debug, marker::PhantomData}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; 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 = Vec; type Failure = GetValueError; } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct GetValueTyped { pub ty: PhantomData, } impl> GiteratedOperation for GetValueTyped { fn operation_name() -> &'static str { "get_value" } type Success = V; type Failure = GetValueError; } #[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)] pub struct ObjectValuePair<'s> { pub object_kind: &'s str, pub value_name: &'s str, } impl<'s> ObjectValuePair<'s> { pub fn new(object_kind: &'s str, value_name: &'s str) -> Self { Self { object_kind, value_name, } } }