use crate::version::IcalVersion;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum Escaper {
V1_0,
#[default]
Modern,
}
impl Escaper {
pub fn for_version(version: IcalVersion) -> Self {
match version {
IcalVersion::V1_0 => Self::V1_0,
IcalVersion::V2_0 => Self::Modern,
}
}
pub fn for_version_str(version: &str) -> Self {
match version.parse() {
Ok(IcalVersion::V1_0) => Self::V1_0,
_ => Self::Modern,
}
}
pub fn has_param_encoding(self) -> bool {
matches!(self, Self::Modern)
}
pub fn has_param_quoting(self) -> bool {
matches!(self, Self::Modern)
}
}