mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 11:42:25 +00:00
refactor from file to resource
This commit is contained in:
@@ -221,10 +221,10 @@ impl Resource for CalendarResource {
|
||||
impl<C: CalendarStore + ?Sized> ResourceService for CalendarResourceService<C> {
|
||||
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<Self::File, Error> {
|
||||
async fn get_resource(&self) -> Result<Self::Resource, Error> {
|
||||
let calendar = self
|
||||
.cal_store
|
||||
.read()
|
||||
@@ -270,7 +270,7 @@ impl<C: CalendarStore + ?Sized> ResourceService for CalendarResourceService<C> {
|
||||
})
|
||||
}
|
||||
|
||||
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<C: CalendarStore + ?Sized> ResourceService for CalendarResourceService<C> {
|
||||
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
|
||||
|
||||
@@ -66,7 +66,7 @@ impl Resource for EventResource {
|
||||
#[async_trait(?Send)]
|
||||
impl<C: CalendarStore + ?Sized> ResourceService for EventResourceService<C> {
|
||||
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<C: CalendarStore + ?Sized> ResourceService for EventResourceService<C> {
|
||||
})
|
||||
}
|
||||
|
||||
async fn get_file(&self) -> Result<Self::File, Self::Error> {
|
||||
async fn get_resource(&self) -> Result<Self::Resource, Self::Error> {
|
||||
let event = self
|
||||
.cal_store
|
||||
.read()
|
||||
@@ -106,11 +106,11 @@ impl<C: CalendarStore + ?Sized> ResourceService for EventResourceService<C> {
|
||||
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
|
||||
|
||||
@@ -88,7 +88,7 @@ impl Resource for PrincipalResource {
|
||||
impl<C: CalendarStore + ?Sized> ResourceService for PrincipalResourceService<C> {
|
||||
type PathComponents = (String,);
|
||||
type MemberType = CalendarResource;
|
||||
type File = PrincipalResource;
|
||||
type Resource = PrincipalResource;
|
||||
type Error = Error;
|
||||
|
||||
async fn new(
|
||||
@@ -112,7 +112,7 @@ impl<C: CalendarStore + ?Sized> ResourceService for PrincipalResourceService<C>
|
||||
})
|
||||
}
|
||||
|
||||
async fn get_file(&self) -> Result<Self::File, Self::Error> {
|
||||
async fn get_resource(&self) -> Result<Self::Resource, Self::Error> {
|
||||
Ok(PrincipalResource {
|
||||
principal: self.principal.to_owned(),
|
||||
})
|
||||
@@ -134,7 +134,7 @@ impl<C: CalendarStore + ?Sized> ResourceService for PrincipalResourceService<C>
|
||||
.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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Self::File, Self::Error> {
|
||||
async fn get_resource(&self) -> Result<Self::Resource, Self::Error> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user