mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 11:42:25 +00:00
xml: Differentiate between ValueSerialize and ValueDeserialize to prevent unwraps
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use derive_more::derive::From;
|
||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||
use rustical_xml::XmlSerialize;
|
||||
|
||||
#[derive(Debug, Clone, XmlDeserialize, XmlSerialize, PartialEq, From)]
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq, From)]
|
||||
pub struct SupportedCalendarComponent {
|
||||
#[xml(ty = "attr")]
|
||||
pub name: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, XmlDeserialize, XmlSerialize, PartialEq)]
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
pub struct SupportedCalendarComponentSet {
|
||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
||||
pub comp: Vec<SupportedCalendarComponent>,
|
||||
|
||||
@@ -29,7 +29,7 @@ pub enum PrincipalProp {
|
||||
Displayname(String),
|
||||
|
||||
// Scheduling Extensions to CalDAV (RFC 6638)
|
||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
||||
CalendarUserType(&'static str),
|
||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||
CalendarUserAddressSet(HrefElement),
|
||||
|
||||
Reference in New Issue
Block a user