diff --git a/src/calendar.rs b/src/calendar.rs index 51e72ed..251cbe7 100644 --- a/src/calendar.rs +++ b/src/calendar.rs @@ -2,7 +2,6 @@ use std::convert::TryFrom; use std::error::Error; use url::Url; -use serde::{Deserialize, Serialize}; use crate::task::Task; use crate::task::TaskId; @@ -10,7 +9,6 @@ use crate::task::TaskId; use bitflags::bitflags; bitflags! { - #[derive(Serialize, Deserialize)] pub struct SupportedComponents: u8 { /// An event, such as a calendar meeting const EVENT = 1; @@ -47,10 +45,9 @@ impl TryFrom for SupportedComponents { /// A Caldav Calendar -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug)] pub struct Calendar { name: String, - #[serde(with="crate::utils::url_serde")] url: Url, supported_components: SupportedComponents, diff --git a/src/utils.rs b/src/utils.rs index 7f54b35..fa80b76 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,7 +1,6 @@ ///! Some utility functions use minidom::Element; -use serde::Deserialize; /// Walks an XML tree and returns every element that has the given name pub fn find_elems>(root: &Element, searched_name: S) -> Vec<&Element> { @@ -51,27 +50,3 @@ pub fn print_xml(element: &Element) { writer.write(&[0x0a]); } - - -/// Used to (de)serialize url::Url -pub mod url_serde{ - use super::*; - - pub fn deserialize<'de, D>(deserializer: D) -> Result - where - D: serde::de::Deserializer<'de> - { - let s = String::deserialize(deserializer)?; - match url::Url::parse(&s) { - Ok(u) => Ok(u), - Err(_) => { return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&s), &"Expected an url")); } - } - } - - pub fn serialize(u: &url::Url, serializer: S) -> Result - where - S: serde::ser::Serializer, - { - serializer.serialize_str( u.as_str() ) - } -}