remove unnecessary enumproperty trait

This commit is contained in:
Lennart
2024-03-27 17:22:38 +01:00
parent 55342309b9
commit e6bc9b0989
5 changed files with 10 additions and 17 deletions

View File

@@ -10,7 +10,7 @@ use rustical_dav::{
use rustical_store::calendar::{Calendar, CalendarStore}; use rustical_store::calendar::{Calendar, CalendarStore};
use serde::Serialize; use serde::Serialize;
use std::sync::Arc; use std::sync::Arc;
use strum::{EnumProperty, EnumString, IntoStaticStr, VariantNames}; use strum::{EnumString, IntoStaticStr, VariantNames};
use tokio::sync::RwLock; use tokio::sync::RwLock;
pub struct CalendarResource<C: CalendarStore + ?Sized> { pub struct CalendarResource<C: CalendarStore + ?Sized> {
@@ -117,20 +117,16 @@ impl Default for UserPrivilegeSet {
} }
} }
#[derive(EnumString, Debug, VariantNames, IntoStaticStr, EnumProperty, Clone)] #[derive(EnumString, Debug, VariantNames, IntoStaticStr, Clone)]
#[strum(serialize_all = "kebab-case")] #[strum(serialize_all = "kebab-case")]
pub enum CalendarProp { pub enum CalendarProp {
Resourcetype, Resourcetype,
CurrentUserPrincipal, CurrentUserPrincipal,
Owner, Owner,
Displayname, Displayname,
// #[strum(props(tagname = "IC:calendar-color"))]
CalendarColor, CalendarColor,
// #[strum(props(tagname = "C:calendar-description"))]
CalendarDescription, CalendarDescription,
// #[strum(props(tagname = "C:supported-calendar-component-set"))]
SupportedCalendarComponentSet, SupportedCalendarComponentSet,
// #[strum(props(tagname = "C:supported-calendar-data"))]
SupportedCalendarData, SupportedCalendarData,
Getcontenttype, Getcontenttype,
CurrentUserPrivilegeSet, CurrentUserPrivilegeSet,

View File

@@ -8,7 +8,7 @@ use rustical_store::calendar::CalendarStore;
use rustical_store::event::Event; use rustical_store::event::Event;
use serde::Serialize; use serde::Serialize;
use std::sync::Arc; use std::sync::Arc;
use strum::{EnumProperty, EnumString, IntoStaticStr, VariantNames}; use strum::{EnumString, IntoStaticStr, VariantNames};
use tokio::sync::RwLock; use tokio::sync::RwLock;
pub struct EventResource<C: CalendarStore + ?Sized> { pub struct EventResource<C: CalendarStore + ?Sized> {
@@ -17,11 +17,10 @@ pub struct EventResource<C: CalendarStore + ?Sized> {
pub event: Event, pub event: Event,
} }
#[derive(EnumString, Debug, VariantNames, IntoStaticStr, EnumProperty, Clone)] #[derive(EnumString, Debug, VariantNames, IntoStaticStr, Clone)]
#[strum(serialize_all = "kebab-case")] #[strum(serialize_all = "kebab-case")]
pub enum EventProp { pub enum EventProp {
Getetag, Getetag,
#[strum(props(tagname = "C:calendar-data"))]
CalendarData, CalendarData,
Getcontenttype, Getcontenttype,
} }

View File

@@ -7,7 +7,7 @@ use rustical_dav::{resource::Resource, xml_snippets::HrefElement};
use rustical_store::calendar::CalendarStore; use rustical_store::calendar::CalendarStore;
use serde::Serialize; use serde::Serialize;
use std::sync::Arc; use std::sync::Arc;
use strum::{EnumProperty, EnumString, IntoStaticStr, VariantNames}; use strum::{EnumString, IntoStaticStr, VariantNames};
use tokio::sync::RwLock; use tokio::sync::RwLock;
use super::calendar::CalendarResource; use super::calendar::CalendarResource;
@@ -39,16 +39,14 @@ pub enum PrincipalPropResponse {
CalendarUserAddressSet(HrefElement), CalendarUserAddressSet(HrefElement),
} }
#[derive(EnumString, Debug, VariantNames, IntoStaticStr, EnumProperty, Clone)] #[derive(EnumString, Debug, VariantNames, IntoStaticStr, Clone)]
#[strum(serialize_all = "kebab-case")] #[strum(serialize_all = "kebab-case")]
pub enum PrincipalProp { pub enum PrincipalProp {
Resourcetype, Resourcetype,
CurrentUserPrincipal, CurrentUserPrincipal,
#[strum(serialize = "principal-URL")] #[strum(serialize = "principal-URL")]
PrincipalUrl, PrincipalUrl,
#[strum(props(tagname = "C:calendar-home-set"))]
CalendarHomeSet, CalendarHomeSet,
#[strum(props(tagname = "C:calendar-user-address-set"))]
CalendarUserAddressSet, CalendarUserAddressSet,
} }

View File

@@ -5,7 +5,7 @@ use rustical_auth::AuthInfo;
use rustical_dav::error::Error; use rustical_dav::error::Error;
use rustical_dav::{resource::Resource, xml_snippets::HrefElement}; use rustical_dav::{resource::Resource, xml_snippets::HrefElement};
use serde::Serialize; use serde::Serialize;
use strum::{EnumProperty, EnumString, IntoStaticStr, VariantNames}; use strum::{EnumString, IntoStaticStr, VariantNames};
pub struct RootResource { pub struct RootResource {
prefix: String, prefix: String,
@@ -13,7 +13,7 @@ pub struct RootResource {
path: String, path: String,
} }
#[derive(EnumString, Debug, VariantNames, EnumProperty, IntoStaticStr, Clone)] #[derive(EnumString, Debug, VariantNames, IntoStaticStr, Clone)]
#[strum(serialize_all = "kebab-case")] #[strum(serialize_all = "kebab-case")]
pub enum RootProp { pub enum RootProp {
Resourcetype, Resourcetype,

View File

@@ -6,7 +6,7 @@ use itertools::Itertools;
use rustical_auth::AuthInfo; use rustical_auth::AuthInfo;
use serde::Serialize; use serde::Serialize;
use std::str::FromStr; use std::str::FromStr;
use strum::{EnumProperty, VariantNames}; use strum::VariantNames;
// A resource is identified by a URI and has properties // A resource is identified by a URI and has properties
// A resource can also be a collection // A resource can also be a collection
@@ -16,7 +16,7 @@ use strum::{EnumProperty, VariantNames};
pub trait Resource: Sized { pub trait Resource: Sized {
type MemberType: Resource; type MemberType: Resource;
type UriComponents: Sized; // defines how the resource URI maps to parameters, i.e. /{principal}/{calendar} -> (String, String) type UriComponents: Sized; // defines how the resource URI maps to parameters, i.e. /{principal}/{calendar} -> (String, String)
type PropType: FromStr + VariantNames + Into<&'static str> + EnumProperty + Clone; type PropType: FromStr + VariantNames + Into<&'static str> + Clone;
type PropResponse: Serialize; type PropResponse: Serialize;
async fn acquire_from_request( async fn acquire_from_request(