mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 17:12:22 +00:00
prop: implement InvalidProperty with Default
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct AddressDataType {
|
||||
#[serde(rename = "@content-type")]
|
||||
@@ -9,7 +9,7 @@ pub struct AddressDataType {
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct SupportedAddressData {
|
||||
#[serde(rename = "CARD:address-data-type", alias = "address-data-type")]
|
||||
@@ -33,7 +33,7 @@ impl Default for SupportedAddressData {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Resourcetype {
|
||||
#[serde(rename = "CARD:addressbook", alias = "addressbook")]
|
||||
@@ -41,21 +41,21 @@ pub struct Resourcetype {
|
||||
collection: (),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum ReportMethod {
|
||||
AddressbookMultiget,
|
||||
SyncCollection,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct ReportWrapper {
|
||||
#[serde(rename = "$value")]
|
||||
report: ReportMethod,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct SupportedReportWrapper {
|
||||
report: ReportWrapper,
|
||||
@@ -70,7 +70,7 @@ impl From<ReportMethod> for SupportedReportWrapper {
|
||||
}
|
||||
|
||||
// RFC 3253 section-3.1.5
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct SupportedReportSet {
|
||||
supported_report: Vec<SupportedReportWrapper>,
|
||||
|
||||
@@ -9,10 +9,10 @@ use actix_web::http::Method;
|
||||
use actix_web::web;
|
||||
use actix_web::{web::Data, HttpRequest};
|
||||
use async_trait::async_trait;
|
||||
use derive_more::derive::{From, Into, TryInto};
|
||||
use derive_more::derive::{From, Into};
|
||||
use rustical_dav::extensions::CommonPropertiesProp;
|
||||
use rustical_dav::privileges::UserPrivilegeSet;
|
||||
use rustical_dav::resource::{InvalidProperty, Resource, ResourceService};
|
||||
use rustical_dav::resource::{Resource, ResourceService};
|
||||
use rustical_store::auth::User;
|
||||
use rustical_store::{Addressbook, AddressbookStore};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -40,7 +40,7 @@ pub enum AddressbookPropName {
|
||||
Getctag,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, From, TryInto)]
|
||||
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum AddressbookProp {
|
||||
// WebDAV (RFC 2518)
|
||||
@@ -69,19 +69,13 @@ pub enum AddressbookProp {
|
||||
|
||||
#[serde(skip_deserializing, untagged)]
|
||||
#[from]
|
||||
#[try_into]
|
||||
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
||||
|
||||
#[serde(untagged)]
|
||||
#[default]
|
||||
Invalid,
|
||||
}
|
||||
|
||||
impl InvalidProperty for AddressbookProp {
|
||||
fn invalid_property(&self) -> bool {
|
||||
matches!(self, Self::Invalid)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, From, Into)]
|
||||
pub struct AddressbookResource(Addressbook);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user