mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 15:18:22 +00:00
save progress: Move from serde::Serialize to XmlSerialize
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
use serde::Serialize;
|
||||
use rustical_xml::XmlSerialize;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
pub struct AddressDataType {
|
||||
#[serde(rename = "@content-type")]
|
||||
#[xml(ty = "attr")]
|
||||
pub content_type: String,
|
||||
#[serde(rename = "@version")]
|
||||
#[xml(ty = "attr")]
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
pub struct SupportedAddressData {
|
||||
#[serde(rename = "CARD:address-data-type", alias = "address-data-type")]
|
||||
// #[serde(rename = "CARD:address-data-type", alias = "address-data-type")]
|
||||
#[xml(flatten)]
|
||||
address_data_type: Vec<AddressDataType>,
|
||||
}
|
||||
|
||||
@@ -33,22 +32,19 @@ impl Default for SupportedAddressData {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
pub enum ReportMethod {
|
||||
AddressbookMultiget,
|
||||
SyncCollection,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
pub struct ReportWrapper {
|
||||
#[serde(rename = "$value")]
|
||||
#[xml(ty = "untagged")]
|
||||
report: ReportMethod,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
pub struct SupportedReportWrapper {
|
||||
report: ReportWrapper,
|
||||
}
|
||||
@@ -62,9 +58,9 @@ impl From<ReportMethod> for SupportedReportWrapper {
|
||||
}
|
||||
|
||||
// RFC 3253 section-3.1.5
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
pub struct SupportedReportSet {
|
||||
#[xml(flatten)]
|
||||
supported_report: Vec<SupportedReportWrapper>,
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ use rustical_dav::privileges::UserPrivilegeSet;
|
||||
use rustical_dav::resource::{Resource, ResourceService};
|
||||
use rustical_store::auth::User;
|
||||
use rustical_store::{Addressbook, AddressbookStore};
|
||||
use rustical_xml::XmlDeserialize;
|
||||
use serde::Serialize;
|
||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
||||
@@ -26,8 +25,7 @@ pub struct AddressbookResourceService<AS: AddressbookStore + ?Sized> {
|
||||
addressbook_id: String,
|
||||
}
|
||||
|
||||
#[derive(XmlDeserialize, Serialize, PartialEq, EnumDiscriminants, Clone)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, EnumDiscriminants, Clone)]
|
||||
#[strum_discriminants(
|
||||
name(AddressbookPropName),
|
||||
derive(EnumString, VariantNames, IntoStaticStr),
|
||||
@@ -39,19 +37,11 @@ pub enum AddressbookProp {
|
||||
Getcontenttype(String),
|
||||
|
||||
// CardDAV (RFC 6352)
|
||||
#[serde(
|
||||
rename = "CARD:addressbook-description",
|
||||
alias = "addressbook-description"
|
||||
)]
|
||||
#[xml(ns = b"urn:ietf:params:xml:ns:carddav")]
|
||||
AddressbookDescription(Option<String>),
|
||||
#[serde(
|
||||
rename = "CARD:supported-address-data",
|
||||
alias = "supported-address-data"
|
||||
)]
|
||||
#[serde(skip_deserializing)]
|
||||
#[xml(skip_deserializing)]
|
||||
#[xml(ns = b"urn:ietf:params:xml:ns:carddav")]
|
||||
SupportedAddressData(SupportedAddressData),
|
||||
#[serde(skip_deserializing)]
|
||||
#[xml(skip_deserializing)]
|
||||
SupportedReportSet(SupportedReportSet),
|
||||
MaxResourceSize(i64),
|
||||
|
||||
Reference in New Issue
Block a user