xml: Differentiate between ValueSerialize and ValueDeserialize to prevent unwraps

This commit is contained in:
Lennart K
2025-01-15 11:05:57 +01:00
parent 4da975c6fb
commit 807335de17
9 changed files with 35 additions and 27 deletions

View File

@@ -9,7 +9,7 @@ use rustical_store::{
synctoken::{format_synctoken, parse_synctoken},
CalendarStore,
};
use rustical_xml::{Value, XmlDeserialize};
use rustical_xml::{ValueDeserialize, ValueSerialize, XmlDeserialize};
use crate::{
calendar_object::resource::{CalendarObjectProp, CalendarObjectResource},
@@ -22,7 +22,7 @@ pub(crate) enum SyncLevel {
Infinity,
}
impl Value for SyncLevel {
impl ValueDeserialize for SyncLevel {
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlDeError> {
Ok(match val {
"1" => Self::One,
@@ -34,6 +34,9 @@ impl Value for SyncLevel {
}
})
}
}
impl ValueSerialize for SyncLevel {
fn serialize(&self) -> String {
match self {
SyncLevel::One => "1",