mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 07:02:24 +00:00
prop: implement InvalidProperty with Default
This commit is contained in:
@@ -19,7 +19,7 @@ impl<R: Resource> Default for CommonPropertiesExtension<R> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
#[derive(Deserialize, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum CommonPropertiesProp<RT: ResourceType> {
|
||||
// WebDAV (RFC 2518)
|
||||
|
||||
@@ -43,7 +43,7 @@ impl Serialize for UserPrivilegeSet {
|
||||
}
|
||||
|
||||
// TODO: implement Deserialize once we need it
|
||||
#[derive(Debug, Clone, Deserialize, Default)]
|
||||
#[derive(Debug, Clone, Deserialize, Default, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct UserPrivilegeSet {
|
||||
privileges: HashSet<UserPrivilege>,
|
||||
|
||||
@@ -32,7 +32,7 @@ impl<T: Serialize + for<'de> Deserialize<'de>> ResourceType for T {}
|
||||
|
||||
pub trait Resource: Clone + 'static {
|
||||
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 PrincipalResource: Resource;
|
||||
type ResourceType: Default + Serialize + for<'de> Deserialize<'de>;
|
||||
@@ -188,6 +188,12 @@ pub trait InvalidProperty {
|
||||
fn invalid_property(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<T: Default + PartialEq> InvalidProperty for T {
|
||||
fn invalid_property(&self) -> bool {
|
||||
self == &T::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
pub trait ResourceService: Sized + 'static {
|
||||
type MemberType: Resource<Error = Self::Error>;
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::any::type_name;
|
||||
use std::marker::PhantomData;
|
||||
use strum::{EnumString, VariantNames};
|
||||
|
||||
#[derive(Deserialize, Serialize, Default, Debug)]
|
||||
#[derive(Deserialize, Serialize, Default, Debug, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Resourcetype {
|
||||
collection: (),
|
||||
|
||||
@@ -9,7 +9,7 @@ pub use tag_name::TagName;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, From)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, From, PartialEq)]
|
||||
pub struct HrefElement {
|
||||
pub href: String,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user