dav: Convert is_collection const to function which will make filesystem access easier

This commit is contained in:
Lennart
2025-06-14 15:21:10 +02:00
parent ca5891314c
commit 529f36ad99
8 changed files with 23 additions and 9 deletions

View File

@@ -97,7 +97,9 @@ impl Resource for CalendarResource {
type Error = Error; type Error = Error;
type Principal = User; type Principal = User;
const IS_COLLECTION: bool = true; fn is_collection(&self) -> bool {
true
}
fn get_resourcetype(&self) -> Resourcetype { fn get_resourcetype(&self) -> Resourcetype {
if self.cal.subscription_url.is_none() { if self.cal.subscription_url.is_none() {

View File

@@ -27,7 +27,9 @@ impl Resource for CalendarObjectResource {
type Error = Error; type Error = Error;
type Principal = User; type Principal = User;
const IS_COLLECTION: bool = false; fn is_collection(&self) -> bool {
false
}
fn get_resourcetype(&self) -> Resourcetype { fn get_resourcetype(&self) -> Resourcetype {
Resourcetype(&[]) Resourcetype(&[])

View File

@@ -29,7 +29,9 @@ impl Resource for PrincipalResource {
type Error = Error; type Error = Error;
type Principal = User; type Principal = User;
const IS_COLLECTION: bool = true; fn is_collection(&self) -> bool {
true
}
fn get_resourcetype(&self) -> Resourcetype { fn get_resourcetype(&self) -> Resourcetype {
Resourcetype(&[ Resourcetype(&[

View File

@@ -32,7 +32,9 @@ impl Resource for AddressObjectResource {
type Error = Error; type Error = Error;
type Principal = User; type Principal = User;
const IS_COLLECTION: bool = false; fn is_collection(&self) -> bool {
false
}
fn get_resourcetype(&self) -> Resourcetype { fn get_resourcetype(&self) -> Resourcetype {
Resourcetype(&[]) Resourcetype(&[])

View File

@@ -38,7 +38,9 @@ impl Resource for AddressbookResource {
type Error = Error; type Error = Error;
type Principal = User; type Principal = User;
const IS_COLLECTION: bool = true; fn is_collection(&self) -> bool {
true
}
fn get_resourcetype(&self) -> Resourcetype { fn get_resourcetype(&self) -> Resourcetype {
Resourcetype(&[ Resourcetype(&[

View File

@@ -29,7 +29,9 @@ impl Resource for PrincipalResource {
type Error = Error; type Error = Error;
type Principal = User; type Principal = User;
const IS_COLLECTION: bool = true; fn is_collection(&self) -> bool {
true
}
fn get_resourcetype(&self) -> Resourcetype { fn get_resourcetype(&self) -> Resourcetype {
Resourcetype(&[ Resourcetype(&[

View File

@@ -37,7 +37,7 @@ pub trait Resource: Clone + Send + 'static {
type Error: From<crate::Error>; type Error: From<crate::Error>;
type Principal: Principal; type Principal: Principal;
const IS_COLLECTION: bool; fn is_collection(&self) -> bool;
fn get_resourcetype(&self) -> Resourcetype; fn get_resourcetype(&self) -> Resourcetype;
@@ -111,7 +111,7 @@ pub trait Resource: Clone + Send + 'static {
) -> Result<ResponseElement<Self::Prop>, Self::Error> { ) -> Result<ResponseElement<Self::Prop>, Self::Error> {
// Collections have a trailing slash // Collections have a trailing slash
let mut path = path.to_string(); let mut path = path.to_string();
if Self::IS_COLLECTION && !path.ends_with('/') { if self.is_collection() && !path.ends_with('/') {
path.push('/'); path.push('/');
} }

View File

@@ -24,7 +24,9 @@ impl<PR: Resource, P: Principal> Resource for RootResource<PR, P> {
type Error = PR::Error; type Error = PR::Error;
type Principal = P; type Principal = P;
const IS_COLLECTION: bool = true; fn is_collection(&self) -> bool {
true
}
fn get_resourcetype(&self) -> Resourcetype { fn get_resourcetype(&self) -> Resourcetype {
Resourcetype(&[ResourcetypeInner( Resourcetype(&[ResourcetypeInner(