dav: Make the get_members function more ergonomic

This commit is contained in:
Lennart
2025-06-09 20:35:25 +02:00
parent 0feaaaaca1
commit 0595920809
14 changed files with 121 additions and 96 deletions

View File

@@ -10,7 +10,7 @@ use futures_util::future::BoxFuture;
use rustical_dav::{
extensions::{CommonPropertiesExtension, CommonPropertiesProp},
privileges::UserPrivilegeSet,
resource::{AxumMethods, PrincipalUri, Resource, ResourceService},
resource::{AxumMethods, PrincipalUri, Resource, ResourceName, ResourceService},
xml::Resourcetype,
};
use rustical_ical::{CalendarObject, UtcDateTime};
@@ -20,24 +20,6 @@ use serde::{Deserialize, Deserializer};
use std::{convert::Infallible, sync::Arc};
use tower::Service;
pub struct CalendarObjectResourceService<C: CalendarStore> {
pub(crate) cal_store: Arc<C>,
}
impl<C: CalendarStore> Clone for CalendarObjectResourceService<C> {
fn clone(&self) -> Self {
Self {
cal_store: self.cal_store.clone(),
}
}
}
impl<C: CalendarStore> CalendarObjectResourceService<C> {
pub fn new(cal_store: Arc<C>) -> Self {
Self { cal_store }
}
}
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq, Hash)]
pub(crate) struct ExpandElement {
#[xml(ty = "attr")]
@@ -86,6 +68,12 @@ pub struct CalendarObjectResource {
pub principal: String,
}
impl ResourceName for CalendarObjectResource {
fn get_name(&self) -> String {
format!("{}.ics", self.object.get_id())
}
}
impl Resource for CalendarObjectResource {
type Prop = CalendarObjectPropWrapper;
type Error = Error;
@@ -163,6 +151,24 @@ pub struct CalendarObjectPathComponents {
pub object_id: String,
}
pub struct CalendarObjectResourceService<C: CalendarStore> {
pub(crate) cal_store: Arc<C>,
}
impl<C: CalendarStore> Clone for CalendarObjectResourceService<C> {
fn clone(&self) -> Self {
Self {
cal_store: self.cal_store.clone(),
}
}
}
impl<C: CalendarStore> CalendarObjectResourceService<C> {
pub fn new(cal_store: Arc<C>) -> Self {
Self { cal_store }
}
}
#[async_trait]
impl<C: CalendarStore> ResourceService for CalendarObjectResourceService<C> {
type PathComponents = CalendarObjectPathComponents;