diff --git a/crates/caldav/src/calendar/resource.rs b/crates/caldav/src/calendar/resource.rs index 6657e99..ea1b334 100644 --- a/crates/caldav/src/calendar/resource.rs +++ b/crates/caldav/src/calendar/resource.rs @@ -221,10 +221,10 @@ impl Resource for CalendarResource { impl ResourceService for CalendarResourceService { type MemberType = EventResource; type PathComponents = (String, String); // principal, calendar_id - type File = CalendarResource; + type Resource = CalendarResource; type Error = Error; - async fn get_file(&self) -> Result { + async fn get_resource(&self) -> Result { let calendar = self .cal_store .read() @@ -270,7 +270,7 @@ impl ResourceService for CalendarResourceService { }) } - async fn save_file(&self, file: Self::File) -> Result<(), Self::Error> { + async fn save_resource(&self, file: Self::Resource) -> Result<(), Self::Error> { self.cal_store .write() .await @@ -283,7 +283,7 @@ impl ResourceService for CalendarResourceService { Ok(()) } - async fn delete_file(&self, use_trashbin: bool) -> Result<(), Self::Error> { + async fn delete_resource(&self, use_trashbin: bool) -> Result<(), Self::Error> { self.cal_store .write() .await diff --git a/crates/caldav/src/event/resource.rs b/crates/caldav/src/event/resource.rs index 0fb3a68..6380c5c 100644 --- a/crates/caldav/src/event/resource.rs +++ b/crates/caldav/src/event/resource.rs @@ -66,7 +66,7 @@ impl Resource for EventResource { #[async_trait(?Send)] impl ResourceService for EventResourceService { type PathComponents = (String, String, String); // principal, calendar, event - type File = EventResource; + type Resource = EventResource; type MemberType = EventResource; type Error = Error; @@ -96,7 +96,7 @@ impl ResourceService for EventResourceService { }) } - async fn get_file(&self) -> Result { + async fn get_resource(&self) -> Result { let event = self .cal_store .read() @@ -106,11 +106,11 @@ impl ResourceService for EventResourceService { Ok(event.into()) } - async fn save_file(&self, _file: Self::File) -> Result<(), Self::Error> { + async fn save_resource(&self, _file: Self::Resource) -> Result<(), Self::Error> { Err(Error::NotImplemented) } - async fn delete_file(&self, use_trashbin: bool) -> Result<(), Self::Error> { + async fn delete_resource(&self, use_trashbin: bool) -> Result<(), Self::Error> { self.cal_store .write() .await diff --git a/crates/caldav/src/principal/mod.rs b/crates/caldav/src/principal/mod.rs index 1e6fd94..d510c45 100644 --- a/crates/caldav/src/principal/mod.rs +++ b/crates/caldav/src/principal/mod.rs @@ -88,7 +88,7 @@ impl Resource for PrincipalResource { impl ResourceService for PrincipalResourceService { type PathComponents = (String,); type MemberType = CalendarResource; - type File = PrincipalResource; + type Resource = PrincipalResource; type Error = Error; async fn new( @@ -112,7 +112,7 @@ impl ResourceService for PrincipalResourceService }) } - async fn get_file(&self) -> Result { + async fn get_resource(&self) -> Result { Ok(PrincipalResource { principal: self.principal.to_owned(), }) @@ -134,7 +134,7 @@ impl ResourceService for PrincipalResourceService .collect()) } - async fn save_file(&self, _file: Self::File) -> Result<(), Self::Error> { + async fn save_resource(&self, _file: Self::Resource) -> Result<(), Self::Error> { Err(Error::NotImplemented) } } diff --git a/crates/caldav/src/root/mod.rs b/crates/caldav/src/root/mod.rs index 4c8ebc9..a89128b 100644 --- a/crates/caldav/src/root/mod.rs +++ b/crates/caldav/src/root/mod.rs @@ -64,7 +64,7 @@ impl Resource for RootResource { impl ResourceService for RootResourceService { type PathComponents = (); type MemberType = RootResource; - type File = RootResource; + type Resource = RootResource; type Error = Error; async fn new( @@ -77,13 +77,13 @@ impl ResourceService for RootResourceService { }) } - async fn get_file(&self) -> Result { + async fn get_resource(&self) -> Result { Ok(RootResource { principal: self.principal.to_owned(), }) } - async fn save_file(&self, _file: Self::File) -> Result<(), Self::Error> { + async fn save_resource(&self, _file: Self::Resource) -> Result<(), Self::Error> { Err(Error::NotImplemented) } } diff --git a/crates/dav/src/methods/delete.rs b/crates/dav/src/methods/delete.rs index a4313f0..5850990 100644 --- a/crates/dav/src/methods/delete.rs +++ b/crates/dav/src/methods/delete.rs @@ -20,7 +20,7 @@ pub async fn route_delete( .unwrap_or(false); let resource_service = R::new(&req, &auth_info, path_components.clone()).await?; - resource_service.delete_file(!no_trash).await?; + resource_service.delete_resource(!no_trash).await?; Ok(HttpResponse::Ok().body("")) } diff --git a/crates/dav/src/methods/propfind.rs b/crates/dav/src/methods/propfind.rs index 17d2c0d..5a64d65 100644 --- a/crates/dav/src/methods/propfind.rs +++ b/crates/dav/src/methods/propfind.rs @@ -48,7 +48,7 @@ pub async fn route_propfind( depth: Depth, ) -> Result< MultistatusElement< - PropstatWrapper<::Prop>, + PropstatWrapper<::Prop>, PropstatWrapper<::Prop>, >, R::Error, @@ -88,7 +88,7 @@ pub async fn route_propfind( } } - let resource = resource_service.get_file().await?; + let resource = resource_service.get_resource().await?; let response = resource.propfind(&prefix, path, props).await?; Ok(MultistatusElement { diff --git a/crates/dav/src/methods/proppatch.rs b/crates/dav/src/methods/proppatch.rs index 0245c27..a666d29 100644 --- a/crates/dav/src/methods/proppatch.rs +++ b/crates/dav/src/methods/proppatch.rs @@ -60,7 +60,7 @@ pub async fn route_proppatch( debug!("{body}"); - let PropertyupdateElement::<::Prop> { operations } = + let PropertyupdateElement::<::Prop> { operations } = quick_xml::de::from_str(&body).map_err(Error::XmlDecodeError)?; // Extract all set property names without verification @@ -76,7 +76,7 @@ pub async fn route_proppatch( }) .collect(); - let mut resource = resource_service.get_file().await?; + let mut resource = resource_service.get_resource().await?; let mut props_ok = Vec::new(); let mut props_conflict = Vec::new(); @@ -105,7 +105,7 @@ pub async fn route_proppatch( } } Operation::Remove(_remove_el) => { - match <::PropName as FromStr>::from_str(&propname) { + match <::PropName as FromStr>::from_str(&propname) { Ok(prop) => { match resource.remove_prop(prop) { Ok(()) => { @@ -131,7 +131,7 @@ pub async fn route_proppatch( if props_not_found.is_empty() && props_conflict.is_empty() { // Only save if no errors occured - resource_service.save_file(resource).await?; + resource_service.save_resource(resource).await?; } Ok(MultistatusElement { diff --git a/crates/dav/src/resource.rs b/crates/dav/src/resource.rs index e75fbc2..38a82df 100644 --- a/crates/dav/src/resource.rs +++ b/crates/dav/src/resource.rs @@ -42,7 +42,7 @@ pub trait InvalidProperty { pub trait ResourceService: Sized { type MemberType: Resource; type PathComponents: Sized + Clone; // defines how the resource URI maps to parameters, i.e. /{principal}/{calendar} -> (String, String) - type File: Resource; + type Resource: Resource; type Error: ResponseError + From + From; async fn new( @@ -58,9 +58,9 @@ pub trait ResourceService: Sized { Ok(vec![]) } - async fn get_file(&self) -> Result; - async fn save_file(&self, file: Self::File) -> Result<(), Self::Error>; - async fn delete_file(&self, _use_trashbin: bool) -> Result<(), Self::Error> { + async fn get_resource(&self) -> Result; + async fn save_resource(&self, file: Self::Resource) -> Result<(), Self::Error>; + async fn delete_resource(&self, _use_trashbin: bool) -> Result<(), Self::Error> { Err(crate::Error::Unauthorized.into()) } }