mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
dav: Refactor proppatch, remove InvalidProperty trait
This commit is contained in:
@@ -12,7 +12,7 @@ use rustical_store::AddressbookStore;
|
||||
use rustical_xml::XmlDeserialize;
|
||||
use serde::Serialize;
|
||||
use std::sync::Arc;
|
||||
use strum::{EnumDiscriminants, EnumString, VariantNames};
|
||||
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
||||
|
||||
pub struct PrincipalResourceService<A: AddressbookStore + ?Sized> {
|
||||
principal: String,
|
||||
@@ -24,10 +24,10 @@ pub struct PrincipalResource {
|
||||
principal: String,
|
||||
}
|
||||
|
||||
#[derive(Default, XmlDeserialize, Serialize, PartialEq, EnumDiscriminants)]
|
||||
#[derive(XmlDeserialize, Serialize, PartialEq, EnumDiscriminants, Clone)]
|
||||
#[strum_discriminants(
|
||||
name(PrincipalPropName),
|
||||
derive(EnumString, VariantNames),
|
||||
derive(EnumString, VariantNames, IntoStaticStr),
|
||||
strum(serialize_all = "kebab-case")
|
||||
)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
@@ -42,12 +42,6 @@ pub enum PrincipalProp {
|
||||
AddressbookHomeSet(HrefElement),
|
||||
#[serde(rename = "CARD:principal-address")]
|
||||
PrincipalAddress(Option<HrefElement>),
|
||||
|
||||
#[serde(other)]
|
||||
#[xml(other)]
|
||||
#[strum_discriminants(strum(disabled))]
|
||||
#[default]
|
||||
Invalid,
|
||||
}
|
||||
|
||||
impl PrincipalResource {
|
||||
@@ -80,9 +74,6 @@ impl Resource for PrincipalResource {
|
||||
PrincipalProp::AddressbookHomeSet(principal_href)
|
||||
}
|
||||
PrincipalPropName::PrincipalAddress => PrincipalProp::PrincipalAddress(None),
|
||||
PrincipalPropName::Invalid => {
|
||||
return Err(rustical_dav::Error::BadRequest("invalid prop name".to_owned()).into())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user