prop: implement InvalidProperty with Default

This commit is contained in:
Lennart
2024-11-04 20:04:46 +01:00
parent 782d886302
commit 05bd8f2aa0
13 changed files with 56 additions and 86 deletions

View File

@@ -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>;