use crate::version::VcardVersion;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum VcardEscaper {
V2_1,
V3_0,
#[default]
V4_0,
}
impl VcardEscaper {
pub fn for_version(version: VcardVersion) -> Self {
match version {
VcardVersion::V2_1 => Self::V2_1,
VcardVersion::V3_0 => Self::V3_0,
VcardVersion::V4_0 => Self::V4_0,
}
}
pub fn for_version_str(version: &str) -> Self {
match version.parse() {
Ok(version) => Self::for_version(version),
Err(_) => Self::default(),
}
}
pub fn has_param_encoding(self) -> bool {
matches!(self, Self::V4_0)
}
}