mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 05:52:19 +00:00
props: skip deserialization where it doesn't make sense
This commit is contained in:
@@ -32,14 +32,14 @@ impl Default for CalendarData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Default, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedCalendarData {
|
pub struct SupportedCalendarData {
|
||||||
#[serde(rename = "C:calendar-data", alias = "calendar-data")]
|
#[serde(rename = "C:calendar-data", alias = "calendar-data")]
|
||||||
calendar_data: CalendarData,
|
calendar_data: CalendarData,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum ReportMethod {
|
pub enum ReportMethod {
|
||||||
CalendarQuery,
|
CalendarQuery,
|
||||||
@@ -47,14 +47,14 @@ pub enum ReportMethod {
|
|||||||
SyncCollection,
|
SyncCollection,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct ReportWrapper {
|
pub struct ReportWrapper {
|
||||||
#[serde(rename = "$value")]
|
#[serde(rename = "$value")]
|
||||||
report: ReportMethod,
|
report: ReportMethod,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedReportWrapper {
|
pub struct SupportedReportWrapper {
|
||||||
report: ReportWrapper,
|
report: ReportWrapper,
|
||||||
@@ -69,7 +69,7 @@ impl From<ReportMethod> for SupportedReportWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RFC 3253 section-3.1.5
|
// RFC 3253 section-3.1.5
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedReportSet {
|
pub struct SupportedReportSet {
|
||||||
supported_report: Vec<SupportedReportWrapper>,
|
supported_report: Vec<SupportedReportWrapper>,
|
||||||
|
|||||||
@@ -71,8 +71,10 @@ pub enum CalendarProp {
|
|||||||
rename = "C:supported-calendar-data",
|
rename = "C:supported-calendar-data",
|
||||||
alias = "supported-calendar-data"
|
alias = "supported-calendar-data"
|
||||||
)]
|
)]
|
||||||
|
#[serde(skip_deserializing)]
|
||||||
SupportedCalendarData(SupportedCalendarData),
|
SupportedCalendarData(SupportedCalendarData),
|
||||||
MaxResourceSize(i64),
|
MaxResourceSize(i64),
|
||||||
|
#[serde(skip_deserializing)]
|
||||||
SupportedReportSet(SupportedReportSet),
|
SupportedReportSet(SupportedReportSet),
|
||||||
|
|
||||||
// Collection Synchronization (RFC 6578)
|
// Collection Synchronization (RFC 6578)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct AddressDataType {
|
pub struct AddressDataType {
|
||||||
#[serde(rename = "@content-type")]
|
#[serde(rename = "@content-type")]
|
||||||
@@ -9,7 +9,7 @@ pub struct AddressDataType {
|
|||||||
pub version: String,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedAddressData {
|
pub struct SupportedAddressData {
|
||||||
#[serde(rename = "CARD:address-data-type", alias = "address-data-type")]
|
#[serde(rename = "CARD:address-data-type", alias = "address-data-type")]
|
||||||
@@ -33,21 +33,21 @@ impl Default for SupportedAddressData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum ReportMethod {
|
pub enum ReportMethod {
|
||||||
AddressbookMultiget,
|
AddressbookMultiget,
|
||||||
SyncCollection,
|
SyncCollection,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct ReportWrapper {
|
pub struct ReportWrapper {
|
||||||
#[serde(rename = "$value")]
|
#[serde(rename = "$value")]
|
||||||
report: ReportMethod,
|
report: ReportMethod,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedReportWrapper {
|
pub struct SupportedReportWrapper {
|
||||||
report: ReportWrapper,
|
report: ReportWrapper,
|
||||||
@@ -62,7 +62,7 @@ impl From<ReportMethod> for SupportedReportWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RFC 3253 section-3.1.5
|
// RFC 3253 section-3.1.5
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedReportSet {
|
pub struct SupportedReportSet {
|
||||||
supported_report: Vec<SupportedReportWrapper>,
|
supported_report: Vec<SupportedReportWrapper>,
|
||||||
|
|||||||
@@ -56,7 +56,9 @@ pub enum AddressbookProp {
|
|||||||
rename = "CARD:supported-address-data",
|
rename = "CARD:supported-address-data",
|
||||||
alias = "supported-address-data"
|
alias = "supported-address-data"
|
||||||
)]
|
)]
|
||||||
|
#[serde(skip_deserializing)]
|
||||||
SupportedAddressData(SupportedAddressData),
|
SupportedAddressData(SupportedAddressData),
|
||||||
|
#[serde(skip_deserializing)]
|
||||||
SupportedReportSet(SupportedReportSet),
|
SupportedReportSet(SupportedReportSet),
|
||||||
MaxResourceSize(i64),
|
MaxResourceSize(i64),
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,9 @@
|
|||||||
use serde::de::{MapAccess, Visitor};
|
|
||||||
use serde::ser::SerializeMap;
|
use serde::ser::SerializeMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct Resourcetype(pub &'static [&'static str]);
|
pub struct Resourcetype(pub &'static [&'static str]);
|
||||||
|
|
||||||
struct ResourcetypeVisitor;
|
|
||||||
|
|
||||||
impl<'de> Visitor<'de> for ResourcetypeVisitor {
|
|
||||||
type Value = Resourcetype;
|
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
formatter.write_str("TagList")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
|
|
||||||
where
|
|
||||||
A: MapAccess<'de>,
|
|
||||||
{
|
|
||||||
while map.next_key::<String>()?.is_some() {}
|
|
||||||
Ok(Resourcetype(&[]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for Resourcetype {
|
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where
|
|
||||||
D: serde::Deserializer<'de>,
|
|
||||||
{
|
|
||||||
deserializer.deserialize_map(ResourcetypeVisitor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for Resourcetype {
|
impl Serialize for Resourcetype {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
|||||||
Reference in New Issue
Block a user