mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 01:12:24 +00:00
Generate everything strum does myself (no duplicate prop names)
This commit is contained in:
@@ -9,6 +9,7 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::Data;
|
||||
use actix_web::{web::Path, HttpRequest};
|
||||
use itertools::Itertools;
|
||||
use quick_xml::name::Namespace;
|
||||
use rustical_store::auth::User;
|
||||
use rustical_xml::Unparsed;
|
||||
use rustical_xml::XmlDeserialize;
|
||||
@@ -97,11 +98,11 @@ pub(crate) async fn route_proppatch<R: ResourceService>(
|
||||
match property {
|
||||
SetPropertyPropWrapper::Valid(prop) => {
|
||||
let propname: <R::Resource as Resource>::PropName = prop.clone().into();
|
||||
let propname: &str = propname.into();
|
||||
let (ns, propname): (Option<Namespace>, &str) = propname.into();
|
||||
match resource.set_prop(prop) {
|
||||
Ok(()) => props_ok.push((None, propname.to_owned())),
|
||||
Ok(()) => props_ok.push((ns, propname.to_owned())),
|
||||
Err(Error::PropReadOnly) => {
|
||||
props_conflict.push((None, propname.to_owned()))
|
||||
props_conflict.push((ns, propname.to_owned()))
|
||||
}
|
||||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
|
||||
@@ -60,7 +60,9 @@ pub enum CommonPropertiesPropName {
|
||||
}
|
||||
|
||||
pub trait Resource: Clone + 'static {
|
||||
type PropName: ResourcePropName + From<Self::Prop> + Into<&'static str>;
|
||||
type PropName: ResourcePropName
|
||||
+ From<Self::Prop>
|
||||
+ Into<(Option<Namespace<'static>>, &'static str)>;
|
||||
type Prop: ResourceProp + PartialEq + Clone + EnumVariants;
|
||||
type Error: ResponseError + From<crate::Error>;
|
||||
type PrincipalResource: Resource + NamedRoute;
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::resource::{NamedRoute, Resource, ResourceService};
|
||||
use crate::xml::{Resourcetype, ResourcetypeInner};
|
||||
use actix_web::dev::ResourceMap;
|
||||
use async_trait::async_trait;
|
||||
use quick_xml::name::Namespace;
|
||||
use rustical_store::auth::User;
|
||||
use rustical_xml::{EnumVariants, XmlDeserialize, XmlSerialize};
|
||||
use serde::Serialize;
|
||||
@@ -22,6 +23,12 @@ impl<PR: Resource> Default for RootResource<PR> {
|
||||
#[strum(serialize_all = "kebab-case")]
|
||||
pub enum RootResourcePropName {}
|
||||
|
||||
impl From<RootResourcePropName> for (Option<Namespace<'static>>, &'static str) {
|
||||
fn from(_value: RootResourcePropName) -> Self {
|
||||
(None, "unreachable")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, Serialize, Clone, PartialEq, EnumVariants)]
|
||||
pub enum RootResourceProp {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user