mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 02:22:21 +00:00
dav: Make the get_members function more ergonomic
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user