use std::{borrow::Cow, marker::PhantomData};
use indexmap::IndexMap;
use crate::jmap::objects::Object;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Comparator<OBJ: Object> {
pub property: Cow<'static, str>,
pub is_ascending: bool,
pub collation: Option<Cow<'static, str>>,
#[serde(flatten, default, skip_serializing_if = "IndexMap::is_empty")]
pub additional_properties: IndexMap<Cow<'static, str>, Cow<'static, str>>,
#[serde(skip)]
pub _ph: PhantomData<fn() -> OBJ>,
}
impl<OBJ: Object> Comparator<OBJ> {
pub fn new(property: Cow<'static, str>) -> Self {
Self {
property,
is_ascending: false,
collation: None,
additional_properties: IndexMap::new(),
_ph: PhantomData,
}
}
_impl!(property: Cow<'static, str>);
_impl!(is_ascending: bool);
_impl!(collation: Option<Cow<'static, str>>);
_impl!(additional_properties: IndexMap<Cow<'static, str>, Cow<'static, str>>);
}