prop: implement InvalidProperty with Default

This commit is contained in:
Lennart
2024-11-04 20:04:46 +01:00
parent 782d886302
commit 05bd8f2aa0
13 changed files with 56 additions and 86 deletions

View File

@@ -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);