From 6a615d8d35f9e0ff527441925a9d511ad62b07d8 Mon Sep 17 00:00:00 2001 From: OMGeeky Date: Sat, 17 Feb 2024 18:08:36 +0100 Subject: [PATCH] expand service --- gdriver-backend/src/service.rs | 104 +++++++++++++++++----- gdriver-common/src/ipc/gdriver_service.rs | 32 +++++++ 2 files changed, 112 insertions(+), 24 deletions(-) diff --git a/gdriver-backend/src/service.rs b/gdriver-backend/src/service.rs index 5f706d8..3b4148e 100644 --- a/gdriver-backend/src/service.rs +++ b/gdriver-backend/src/service.rs @@ -15,6 +15,86 @@ struct GdriverServer { drive: Arc>, } impl GDriverService for GdriverServer { + async fn get_file_by_path( + self, + context: ::tarpc::context::Context, + path: PathBuf, + ) -> StdResult { + todo!() + } + + async fn write_local_change( + self, + context: ::tarpc::context::Context, + id: DriveId, + ) -> StdResult<(), WriteLocalChangeError> { + todo!() + } + + async fn get_metadata_for_file( + self, + context: ::tarpc::context::Context, + id: DriveId, + ) -> StdResult<(), GetMetadataError> { + todo!() + } + + async fn download_content_for_file( + self, + context: ::tarpc::context::Context, + id: DriveId, + ) -> StdResult<(), GetContentError> { + todo!() + } + + async fn list_files_in_directory( + self, + context: ::tarpc::context::Context, + id: DriveId, + ) -> StdResult<(), GetFileListError> { + todo!() + } + + async fn mark_file_as_deleted( + self, + context: ::tarpc::context::Context, + id: DriveId, + ) -> StdResult<(), MarkFileAsDeletedError> { + todo!() + } + + async fn mark_file_for_keeping_local( + self, + context: ::tarpc::context::Context, + id: DriveId, + ) -> StdResult<(), MarkFileForKeepingLocalError> { + todo!() + } + + async fn unmark_file_for_keeping_local( + self, + context: ::tarpc::context::Context, + id: DriveId, + ) -> StdResult<(), UnmarkFileForKeepingLocalError> { + todo!() + } + + #[doc = " Returns true if the file was had remote changes and was updadet"] + async fn update_changes_for_file( + self, + context: ::tarpc::context::Context, + id: DriveId, + ) -> StdResult { + todo!() + } + + async fn update_changes( + self, + context: ::tarpc::context::Context, + ) -> StdResult<(), UpdateChangesError> { + todo!() + } + async fn do_something2( self, _: ::tarpc::context::Context, @@ -51,30 +131,6 @@ impl GDriverService for GdriverServer { } } } - - async fn get_file_by_path( - self, - context: ::tarpc::context::Context, - path: PathBuf, - ) -> StdResult { - todo!() - } - - #[doc = " Returns true if the file was had remote changes and was updadet"] - async fn update_changes_for_file( - self, - context: ::tarpc::context::Context, - id: DriveId, - ) -> StdResult { - todo!() - } - - async fn update_changes( - self, - context: ::tarpc::context::Context, - ) -> StdResult<(), UpdateChangesError> { - todo!() - } } async fn long_running_task(drive: &Arc>) { thread::sleep(Duration::seconds(10).to_std().unwrap()); diff --git a/gdriver-common/src/ipc/gdriver_service.rs b/gdriver-common/src/ipc/gdriver_service.rs index 5bfb3a0..08d8d63 100644 --- a/gdriver-common/src/ipc/gdriver_service.rs +++ b/gdriver-common/src/ipc/gdriver_service.rs @@ -8,6 +8,17 @@ use crate::drive_structure::drive_id::DriveId; #[tarpc::service] pub trait GDriverService { async fn get_file_by_path(path: PathBuf) -> StdResult; + async fn write_local_change(id: DriveId) -> StdResult<(), WriteLocalChangeError>; + async fn get_metadata_for_file(id: DriveId) -> StdResult<(), GetMetadataError>; + async fn download_content_for_file(id: DriveId) -> StdResult<(), GetContentError>; + async fn list_files_in_directory(id: DriveId) -> StdResult<(), GetFileListError>; + async fn mark_file_as_deleted(id: DriveId) -> StdResult<(), MarkFileAsDeletedError>; + async fn mark_file_for_keeping_local( + id: DriveId, + ) -> StdResult<(), MarkFileForKeepingLocalError>; + async fn unmark_file_for_keeping_local( + id: DriveId, + ) -> StdResult<(), UnmarkFileForKeepingLocalError>; /// Returns true if the file was had remote changes and was updadet async fn update_changes_for_file(id: DriveId) -> StdResult; async fn update_changes() -> StdResult<(), UpdateChangesError>; @@ -31,3 +42,24 @@ pub enum BackendActionError { pub enum GetFileByPathError {} #[derive(Debug, Serialize, Deserialize)] pub enum UpdateChangesError {} +#[derive(Debug, Serialize, Deserialize)] +pub enum WriteLocalChangeError { + RemoteChanged, + UnknownId, + NotAllowed, + Other, +} +#[derive(Debug, Serialize, Deserialize)] +pub enum GetMetadataError {} +#[derive(Debug, Serialize, Deserialize)] +pub enum GetContentError {} +//#[derive(Debug, Serialize, Deserialize)] +//pub enum GetContentError {} +#[derive(Debug, Serialize, Deserialize)] +pub enum GetFileListError {} +#[derive(Debug, Serialize, Deserialize)] +pub enum MarkFileAsDeletedError {} +#[derive(Debug, Serialize, Deserialize)] +pub enum MarkFileForKeepingLocalError {} +#[derive(Debug, Serialize, Deserialize)] +pub enum UnmarkFileForKeepingLocalError {}