mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
prop: implement InvalidProperty with Default
This commit is contained in:
@@ -1,20 +1,20 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedCalendarComponent {
|
pub struct SupportedCalendarComponent {
|
||||||
#[serde(rename = "@name")]
|
#[serde(rename = "@name")]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedCalendarComponentSet {
|
pub struct SupportedCalendarComponentSet {
|
||||||
#[serde(rename = "C:comp")]
|
#[serde(rename = "C:comp")]
|
||||||
pub comp: Vec<SupportedCalendarComponent>,
|
pub comp: Vec<SupportedCalendarComponent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct CalendarData {
|
pub struct CalendarData {
|
||||||
#[serde(rename = "@content-type")]
|
#[serde(rename = "@content-type")]
|
||||||
@@ -32,14 +32,14 @@ impl Default for CalendarData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedCalendarData {
|
pub struct SupportedCalendarData {
|
||||||
#[serde(rename = "C:calendar-data", alias = "calendar-data")]
|
#[serde(rename = "C:calendar-data", alias = "calendar-data")]
|
||||||
calendar_data: CalendarData,
|
calendar_data: CalendarData,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Resourcetype {
|
pub struct Resourcetype {
|
||||||
#[serde(rename = "C:calendar", alias = "calendar")]
|
#[serde(rename = "C:calendar", alias = "calendar")]
|
||||||
@@ -47,7 +47,7 @@ pub struct Resourcetype {
|
|||||||
collection: (),
|
collection: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum ReportMethod {
|
pub enum ReportMethod {
|
||||||
CalendarQuery,
|
CalendarQuery,
|
||||||
@@ -55,14 +55,14 @@ pub enum ReportMethod {
|
|||||||
SyncCollection,
|
SyncCollection,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct ReportWrapper {
|
pub struct ReportWrapper {
|
||||||
#[serde(rename = "$value")]
|
#[serde(rename = "$value")]
|
||||||
report: ReportMethod,
|
report: ReportMethod,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedReportWrapper {
|
pub struct SupportedReportWrapper {
|
||||||
report: ReportWrapper,
|
report: ReportWrapper,
|
||||||
@@ -77,7 +77,7 @@ impl From<ReportMethod> for SupportedReportWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RFC 3253 section-3.1.5
|
// RFC 3253 section-3.1.5
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedReportSet {
|
pub struct SupportedReportSet {
|
||||||
supported_report: Vec<SupportedReportWrapper>,
|
supported_report: Vec<SupportedReportWrapper>,
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ use actix_web::http::Method;
|
|||||||
use actix_web::web;
|
use actix_web::web;
|
||||||
use actix_web::{web::Data, HttpRequest};
|
use actix_web::{web::Data, HttpRequest};
|
||||||
use async_trait::async_trait;
|
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::extensions::CommonPropertiesProp;
|
||||||
use rustical_dav::privileges::UserPrivilegeSet;
|
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::auth::User;
|
||||||
use rustical_store::{Calendar, CalendarStore};
|
use rustical_store::{Calendar, CalendarStore};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -47,7 +47,7 @@ pub enum CalendarPropName {
|
|||||||
Getctag,
|
Getctag,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, From, TryInto)]
|
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum CalendarProp {
|
pub enum CalendarProp {
|
||||||
// WebDAV (RFC 2518)
|
// WebDAV (RFC 2518)
|
||||||
@@ -84,19 +84,13 @@ pub enum CalendarProp {
|
|||||||
|
|
||||||
#[serde(skip_deserializing, untagged)]
|
#[serde(skip_deserializing, untagged)]
|
||||||
#[from]
|
#[from]
|
||||||
#[try_into]
|
|
||||||
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
||||||
|
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
#[default]
|
||||||
Invalid,
|
Invalid,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InvalidProperty for CalendarProp {
|
|
||||||
fn invalid_property(&self) -> bool {
|
|
||||||
matches!(self, Self::Invalid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, From, Into)]
|
#[derive(Clone, Debug, From, Into)]
|
||||||
pub struct CalendarResource(Calendar);
|
pub struct CalendarResource(Calendar);
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ use super::methods::{get_event, put_event};
|
|||||||
use crate::{principal::PrincipalResource, Error};
|
use crate::{principal::PrincipalResource, Error};
|
||||||
use actix_web::{dev::ResourceMap, web::Data, HttpRequest};
|
use actix_web::{dev::ResourceMap, web::Data, HttpRequest};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use derive_more::derive::{From, Into, TryInto};
|
use derive_more::derive::{From, Into};
|
||||||
use rustical_dav::{
|
use rustical_dav::{
|
||||||
extensions::CommonPropertiesProp,
|
extensions::CommonPropertiesProp,
|
||||||
privileges::UserPrivilegeSet,
|
privileges::UserPrivilegeSet,
|
||||||
resource::{InvalidProperty, Resource, ResourceService},
|
resource::{Resource, ResourceService},
|
||||||
};
|
};
|
||||||
use rustical_store::{auth::User, CalendarObject, CalendarStore};
|
use rustical_store::{auth::User, CalendarObject, CalendarStore};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -29,7 +29,7 @@ pub enum CalendarObjectPropName {
|
|||||||
Getcontenttype,
|
Getcontenttype,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, From, TryInto)]
|
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum CalendarObjectProp {
|
pub enum CalendarObjectProp {
|
||||||
// WebDAV (RFC 2518)
|
// WebDAV (RFC 2518)
|
||||||
@@ -42,19 +42,13 @@ pub enum CalendarObjectProp {
|
|||||||
|
|
||||||
#[serde(skip_deserializing, untagged)]
|
#[serde(skip_deserializing, untagged)]
|
||||||
#[from]
|
#[from]
|
||||||
#[try_into]
|
|
||||||
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
||||||
|
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
#[default]
|
||||||
Invalid,
|
Invalid,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InvalidProperty for CalendarObjectProp {
|
|
||||||
fn invalid_property(&self) -> bool {
|
|
||||||
matches!(self, Self::Invalid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, From, Into)]
|
#[derive(Clone, From, Into)]
|
||||||
pub struct CalendarObjectResource {
|
pub struct CalendarObjectResource {
|
||||||
pub object: CalendarObject,
|
pub object: CalendarObject,
|
||||||
@@ -62,7 +56,7 @@ pub struct CalendarObjectResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: set correct resourcetype
|
// TODO: set correct resourcetype
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Resourcetype {
|
pub struct Resourcetype {
|
||||||
collection: (),
|
collection: (),
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ use actix_web::dev::ResourceMap;
|
|||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use actix_web::HttpRequest;
|
use actix_web::HttpRequest;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use derive_more::derive::{From, TryInto};
|
use derive_more::derive::From;
|
||||||
use rustical_dav::extensions::CommonPropertiesProp;
|
use rustical_dav::extensions::CommonPropertiesProp;
|
||||||
use rustical_dav::privileges::UserPrivilegeSet;
|
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_dav::xml::HrefElement;
|
||||||
use rustical_store::auth::User;
|
use rustical_store::auth::User;
|
||||||
use rustical_store::CalendarStore;
|
use rustical_store::CalendarStore;
|
||||||
@@ -25,14 +25,14 @@ pub struct PrincipalResource {
|
|||||||
principal: String,
|
principal: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Default, Debug)]
|
#[derive(Deserialize, Serialize, Default, Debug, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Resourcetype {
|
pub struct Resourcetype {
|
||||||
principal: (),
|
principal: (),
|
||||||
collection: (),
|
collection: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, From, TryInto)]
|
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum PrincipalProp {
|
pub enum PrincipalProp {
|
||||||
// WebDAV Access Control (RFC 3744)
|
// WebDAV Access Control (RFC 3744)
|
||||||
@@ -47,19 +47,13 @@ pub enum PrincipalProp {
|
|||||||
|
|
||||||
#[serde(skip_deserializing, untagged)]
|
#[serde(skip_deserializing, untagged)]
|
||||||
#[from]
|
#[from]
|
||||||
#[try_into]
|
|
||||||
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
||||||
|
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
#[default]
|
||||||
Invalid,
|
Invalid,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InvalidProperty for PrincipalProp {
|
|
||||||
fn invalid_property(&self) -> bool {
|
|
||||||
matches!(self, Self::Invalid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(EnumString, VariantNames, Clone)]
|
#[derive(EnumString, VariantNames, Clone)]
|
||||||
#[strum(serialize_all = "kebab-case")]
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum PrincipalPropName {
|
pub enum PrincipalPropName {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use crate::{principal::PrincipalResource, Error};
|
use crate::{principal::PrincipalResource, Error};
|
||||||
use actix_web::{dev::ResourceMap, web::Data, HttpRequest};
|
use actix_web::{dev::ResourceMap, web::Data, HttpRequest};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use derive_more::derive::{From, Into, TryInto};
|
use derive_more::derive::{From, Into};
|
||||||
use rustical_dav::{
|
use rustical_dav::{
|
||||||
extensions::CommonPropertiesProp,
|
extensions::CommonPropertiesProp,
|
||||||
privileges::UserPrivilegeSet,
|
privileges::UserPrivilegeSet,
|
||||||
resource::{InvalidProperty, Resource, ResourceService},
|
resource::{Resource, ResourceService},
|
||||||
};
|
};
|
||||||
use rustical_store::{auth::User, AddressObject, AddressbookStore};
|
use rustical_store::{auth::User, AddressObject, AddressbookStore};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -30,7 +30,7 @@ pub enum AddressObjectPropName {
|
|||||||
Getcontenttype,
|
Getcontenttype,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, From, TryInto)]
|
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum AddressObjectProp {
|
pub enum AddressObjectProp {
|
||||||
// WebDAV (RFC 2518)
|
// WebDAV (RFC 2518)
|
||||||
@@ -43,19 +43,13 @@ pub enum AddressObjectProp {
|
|||||||
|
|
||||||
#[serde(skip_deserializing, untagged)]
|
#[serde(skip_deserializing, untagged)]
|
||||||
#[from]
|
#[from]
|
||||||
#[try_into]
|
|
||||||
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
||||||
|
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
#[default]
|
||||||
Invalid,
|
Invalid,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InvalidProperty for AddressObjectProp {
|
|
||||||
fn invalid_property(&self) -> bool {
|
|
||||||
matches!(self, Self::Invalid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, From, Into)]
|
#[derive(Clone, From, Into)]
|
||||||
pub struct AddressObjectResource {
|
pub struct AddressObjectResource {
|
||||||
pub object: AddressObject,
|
pub object: AddressObject,
|
||||||
@@ -63,7 +57,7 @@ pub struct AddressObjectResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: set correct resourcetype
|
// TODO: set correct resourcetype
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Resourcetype {
|
pub struct Resourcetype {
|
||||||
collection: (),
|
collection: (),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct AddressDataType {
|
pub struct AddressDataType {
|
||||||
#[serde(rename = "@content-type")]
|
#[serde(rename = "@content-type")]
|
||||||
@@ -9,7 +9,7 @@ pub struct AddressDataType {
|
|||||||
pub version: String,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedAddressData {
|
pub struct SupportedAddressData {
|
||||||
#[serde(rename = "CARD:address-data-type", alias = "address-data-type")]
|
#[serde(rename = "CARD:address-data-type", alias = "address-data-type")]
|
||||||
@@ -33,7 +33,7 @@ impl Default for SupportedAddressData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Resourcetype {
|
pub struct Resourcetype {
|
||||||
#[serde(rename = "CARD:addressbook", alias = "addressbook")]
|
#[serde(rename = "CARD:addressbook", alias = "addressbook")]
|
||||||
@@ -41,21 +41,21 @@ pub struct Resourcetype {
|
|||||||
collection: (),
|
collection: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum ReportMethod {
|
pub enum ReportMethod {
|
||||||
AddressbookMultiget,
|
AddressbookMultiget,
|
||||||
SyncCollection,
|
SyncCollection,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct ReportWrapper {
|
pub struct ReportWrapper {
|
||||||
#[serde(rename = "$value")]
|
#[serde(rename = "$value")]
|
||||||
report: ReportMethod,
|
report: ReportMethod,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedReportWrapper {
|
pub struct SupportedReportWrapper {
|
||||||
report: ReportWrapper,
|
report: ReportWrapper,
|
||||||
@@ -70,7 +70,7 @@ impl From<ReportMethod> for SupportedReportWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RFC 3253 section-3.1.5
|
// RFC 3253 section-3.1.5
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SupportedReportSet {
|
pub struct SupportedReportSet {
|
||||||
supported_report: Vec<SupportedReportWrapper>,
|
supported_report: Vec<SupportedReportWrapper>,
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ use actix_web::http::Method;
|
|||||||
use actix_web::web;
|
use actix_web::web;
|
||||||
use actix_web::{web::Data, HttpRequest};
|
use actix_web::{web::Data, HttpRequest};
|
||||||
use async_trait::async_trait;
|
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::extensions::CommonPropertiesProp;
|
||||||
use rustical_dav::privileges::UserPrivilegeSet;
|
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::auth::User;
|
||||||
use rustical_store::{Addressbook, AddressbookStore};
|
use rustical_store::{Addressbook, AddressbookStore};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -40,7 +40,7 @@ pub enum AddressbookPropName {
|
|||||||
Getctag,
|
Getctag,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, From, TryInto)]
|
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum AddressbookProp {
|
pub enum AddressbookProp {
|
||||||
// WebDAV (RFC 2518)
|
// WebDAV (RFC 2518)
|
||||||
@@ -69,19 +69,13 @@ pub enum AddressbookProp {
|
|||||||
|
|
||||||
#[serde(skip_deserializing, untagged)]
|
#[serde(skip_deserializing, untagged)]
|
||||||
#[from]
|
#[from]
|
||||||
#[try_into]
|
|
||||||
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
||||||
|
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
#[default]
|
||||||
Invalid,
|
Invalid,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InvalidProperty for AddressbookProp {
|
|
||||||
fn invalid_property(&self) -> bool {
|
|
||||||
matches!(self, Self::Invalid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, From, Into)]
|
#[derive(Clone, Debug, From, Into)]
|
||||||
pub struct AddressbookResource(Addressbook);
|
pub struct AddressbookResource(Addressbook);
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ use actix_web::dev::ResourceMap;
|
|||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use actix_web::HttpRequest;
|
use actix_web::HttpRequest;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use derive_more::derive::{From, TryInto};
|
use derive_more::derive::From;
|
||||||
use rustical_dav::extensions::CommonPropertiesProp;
|
use rustical_dav::extensions::CommonPropertiesProp;
|
||||||
use rustical_dav::privileges::UserPrivilegeSet;
|
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_dav::xml::HrefElement;
|
||||||
use rustical_store::auth::User;
|
use rustical_store::auth::User;
|
||||||
use rustical_store::AddressbookStore;
|
use rustical_store::AddressbookStore;
|
||||||
@@ -25,14 +25,14 @@ pub struct PrincipalResource {
|
|||||||
principal: String,
|
principal: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Default, Debug)]
|
#[derive(Deserialize, Serialize, Default, Debug, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Resourcetype {
|
pub struct Resourcetype {
|
||||||
principal: (),
|
principal: (),
|
||||||
collection: (),
|
collection: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, From, TryInto)]
|
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum PrincipalProp {
|
pub enum PrincipalProp {
|
||||||
// WebDAV Access Control (RFC 3744)
|
// WebDAV Access Control (RFC 3744)
|
||||||
@@ -47,20 +47,14 @@ pub enum PrincipalProp {
|
|||||||
|
|
||||||
#[serde(skip_deserializing, untagged)]
|
#[serde(skip_deserializing, untagged)]
|
||||||
#[from]
|
#[from]
|
||||||
#[try_into]
|
|
||||||
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
ExtCommonProperties(CommonPropertiesProp<Resourcetype>),
|
||||||
|
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
#[default]
|
||||||
Invalid,
|
Invalid,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InvalidProperty for PrincipalProp {
|
#[derive(EnumString, VariantNames, Clone)]
|
||||||
fn invalid_property(&self) -> bool {
|
|
||||||
matches!(self, Self::Invalid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(EnumString, VariantNames, Clone, From, TryInto)]
|
|
||||||
#[strum(serialize_all = "kebab-case")]
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum PrincipalPropName {
|
pub enum PrincipalPropName {
|
||||||
#[strum(serialize = "principal-URL")]
|
#[strum(serialize = "principal-URL")]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ impl<R: Resource> Default for CommonPropertiesExtension<R> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum CommonPropertiesProp<RT: ResourceType> {
|
pub enum CommonPropertiesProp<RT: ResourceType> {
|
||||||
// WebDAV (RFC 2518)
|
// WebDAV (RFC 2518)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ impl Serialize for UserPrivilegeSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement Deserialize once we need it
|
// TODO: implement Deserialize once we need it
|
||||||
#[derive(Debug, Clone, Deserialize, Default)]
|
#[derive(Debug, Clone, Deserialize, Default, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct UserPrivilegeSet {
|
pub struct UserPrivilegeSet {
|
||||||
privileges: HashSet<UserPrivilege>,
|
privileges: HashSet<UserPrivilege>,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ impl<T: Serialize + for<'de> Deserialize<'de>> ResourceType for T {}
|
|||||||
|
|
||||||
pub trait Resource: Clone + 'static {
|
pub trait Resource: Clone + 'static {
|
||||||
type PropName: ResourcePropName;
|
type PropName: ResourcePropName;
|
||||||
type Prop: ResourceProp + From<CommonPropertiesProp<Self::ResourceType>>;
|
type Prop: ResourceProp + From<CommonPropertiesProp<Self::ResourceType>> + PartialEq;
|
||||||
type Error: ResponseError + From<crate::Error>;
|
type Error: ResponseError + From<crate::Error>;
|
||||||
type PrincipalResource: Resource;
|
type PrincipalResource: Resource;
|
||||||
type ResourceType: Default + Serialize + for<'de> Deserialize<'de>;
|
type ResourceType: Default + Serialize + for<'de> Deserialize<'de>;
|
||||||
@@ -188,6 +188,12 @@ pub trait InvalidProperty {
|
|||||||
fn invalid_property(&self) -> bool;
|
fn invalid_property(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Default + PartialEq> InvalidProperty for T {
|
||||||
|
fn invalid_property(&self) -> bool {
|
||||||
|
self == &T::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
pub trait ResourceService: Sized + 'static {
|
pub trait ResourceService: Sized + 'static {
|
||||||
type MemberType: Resource<Error = Self::Error>;
|
type MemberType: Resource<Error = Self::Error>;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use std::any::type_name;
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use strum::{EnumString, VariantNames};
|
use strum::{EnumString, VariantNames};
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Default, Debug)]
|
#[derive(Deserialize, Serialize, Default, Debug, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Resourcetype {
|
pub struct Resourcetype {
|
||||||
collection: (),
|
collection: (),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ pub use tag_name::TagName;
|
|||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, From)]
|
#[derive(Debug, Clone, Deserialize, Serialize, From, PartialEq)]
|
||||||
pub struct HrefElement {
|
pub struct HrefElement {
|
||||||
pub href: String,
|
pub href: String,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user