use core::hash::{Hash, Hasher};
use alloc::string::String;
use crate::path::VdirPath;
pub mod create;
pub mod delete;
pub mod list;
pub mod rename;
pub mod update;
pub(crate) const DISPLAYNAME: &str = "displayname";
pub(crate) const DESCRIPTION: &str = "description";
pub(crate) const COLOR: &str = "color";
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct VdirCollection {
pub path: VdirPath,
pub display_name: Option<String>,
pub description: Option<String>,
pub color: Option<String>,
}
impl VdirCollection {
pub fn from_path(path: impl Into<VdirPath>) -> Self {
Self {
path: path.into(),
display_name: None,
description: None,
color: None,
}
}
pub fn id(&self) -> &str {
self.path.file_name().unwrap_or("")
}
}
impl Hash for VdirCollection {
fn hash<H: Hasher>(&self, state: &mut H) {
self.path.hash(state);
}
}
impl AsRef<VdirPath> for VdirCollection {
fn as_ref(&self) -> &VdirPath {
&self.path
}
}
impl From<VdirPath> for VdirCollection {
fn from(path: VdirPath) -> Self {
Self::from_path(path)
}
}