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

@@ -4,10 +4,10 @@ use actix_web::dev::ResourceMap;
use actix_web::web::Data;
use actix_web::HttpRequest;
use async_trait::async_trait;
use derive_more::derive::{From, TryInto};
use derive_more::derive::From;
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_dav::xml::HrefElement;
use rustical_store::auth::User;
use rustical_store::AddressbookStore;
@@ -25,14 +25,14 @@ pub struct PrincipalResource {
principal: String,
}
#[derive(Deserialize, Serialize, Default, Debug)]
#[derive(Deserialize, Serialize, Default, Debug, PartialEq)]
#[serde(rename_all = "kebab-case")]
pub struct Resourcetype {
principal: (),
collection: (),
}
#[derive(Deserialize, Serialize, From, TryInto)]
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
#[serde(rename_all = "kebab-case")]
pub enum PrincipalProp {
// WebDAV Access Control (RFC 3744)
@@ -47,20 +47,14 @@ pub enum PrincipalProp {
#[serde(skip_deserializing, untagged)]
#[from]
#[try_into]
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
#[serde(untagged)]
#[default]
Invalid,
}
impl InvalidProperty for PrincipalProp {
fn invalid_property(&self) -> bool {
matches!(self, Self::Invalid)
}
}
#[derive(EnumString, VariantNames, Clone, From, TryInto)]
#[derive(EnumString, VariantNames, Clone)]
#[strum(serialize_all = "kebab-case")]
pub enum PrincipalPropName {
#[strum(serialize = "principal-URL")]