use libdav::{PropertyName, names};
use crate::base::Property;
#[non_exhaustive]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum CalendarProperty {
Colour,
DisplayName,
Description,
Order,
}
impl CalendarProperty {
#[must_use]
pub fn dav_propname(&self) -> &PropertyName<'_, '_> {
match self {
CalendarProperty::Colour => &names::CALENDAR_COLOUR,
CalendarProperty::DisplayName => &names::DISPLAY_NAME,
CalendarProperty::Description => &names::CALENDAR_DESCRIPTION,
CalendarProperty::Order => &names::CALENDAR_ORDER,
}
}
#[must_use]
pub fn name(&self) -> &str {
match self {
CalendarProperty::DisplayName => "displayname",
CalendarProperty::Colour => "color",
CalendarProperty::Description => "description",
CalendarProperty::Order => "order",
}
}
#[must_use]
pub fn known_properties() -> &'static [Property] {
&[
Property::Calendar(CalendarProperty::DisplayName),
Property::Calendar(CalendarProperty::Colour),
Property::Calendar(CalendarProperty::Description),
Property::Calendar(CalendarProperty::Order),
]
}
#[must_use]
pub fn filename(&self) -> &'static str {
match self {
CalendarProperty::DisplayName => "displayname",
CalendarProperty::Colour => "color",
CalendarProperty::Description => "description",
CalendarProperty::Order => "order",
}
}
}
impl From<CalendarProperty> for Property {
fn from(value: CalendarProperty) -> Self {
Property::Calendar(value)
}
}
#[cfg(test)]
mod tests {
use crate::base::Storage;
#[test]
fn test_storage_is_object_safe() {
#[allow(dead_code)]
fn dummy(_: Box<dyn Storage>) {}
}
}