diff options
| author | jakka <jakka@jakka.su> | 2025-10-01 12:57:32 +0300 |
|---|---|---|
| committer | jakka <jakka@jakka.su> | 2025-10-01 12:57:32 +0300 |
| commit | 228f24cb3020b719540fc9665e4aff21528fc69e (patch) | |
| tree | 83194bfda6c6d97ffec81aef2545802b859b4e5f /src/sync_lib/traits.rs | |
| parent | c177ba7a49caf63582719a4086e5032e2c939cfa (diff) | |
broke down modules and renamed them
Diffstat (limited to 'src/sync_lib/traits.rs')
| -rw-r--r-- | src/sync_lib/traits.rs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/sync_lib/traits.rs b/src/sync_lib/traits.rs new file mode 100644 index 0000000..1f8e1dd --- /dev/null +++ b/src/sync_lib/traits.rs @@ -0,0 +1,67 @@ +use std::{collections::HashMap, path::PathBuf}; + +use crate::sync_lib::types::*; + +type Result<T> = std::result::Result<T, HydrusError>; + +/// Trait for accessing and managing keys and services. +pub trait AccessManagement { + /// Register a new external program with the client. This requires the 'add from api request' mini-dialog under services->review services to be open, otherwise it will 403. + fn request_new_permissions( + &self, + name: &str, + permissions: &[HydrusPermissions], + ) -> Result<String>; + /// Get a new session key. + fn get_session_key(&self) -> Result<String>; + /// Check your access key is valid. + fn verify_access_key(&self, key: &str) -> Result<KeyInfo>; + /// Ask the client about a specific service by providing its name. + fn get_service_name(&self, name: &str) -> Result<Service>; + /// Ask the client about a specific service by providing its key. + fn get_service_key(&self, key: &str) -> Result<Service>; + /// Ask the client about its services. + fn get_services(&self) -> Result<HashMap<String, Service>>; +} + +/// Trait for importing and deleting files. +pub trait ImportingAndDeletingFiles { + /// Tell the client to import a file by providing a local (hydrus-local) file path. + fn add_file_via_path( + &self, + path: PathBuf, + delete: Option<bool>, + domains: Option<FileDomain>, + ) -> Result<AddFileResponse>; + /// Tell the client to import a file by sending the file. + fn add_file_via_file(&self, file: PathBuf) -> Result<AddFileResponse>; + /// Tell the client to send files to the trash. + fn delete_files( + &self, + file: HydrusFile, + domain: Option<FileDomain>, + reason: Option<String>, + ) -> Result<()>; + /// Tell the client to restore files that were previously deleted to their old file service(s). + fn undelete_files(&self, file: HydrusFile, domain: Option<FileDomain>) -> Result<()>; + /// Tell the client to forget that it once deleted files. + fn clear_file_deletion_records(&self, file: HydrusFile) -> Result<()>; + /// Copy files from one local file domain to another. + fn migrate_files(&self, file: HydrusFile, domain: FileDomain) -> Result<()>; + /// Tell the client to archive inboxed files. + fn archive_files(&self, file: HydrusFile) -> Result<()>; + /// Tell the client re-inbox archived files. + fn unarchive_files(&self, file: HydrusFile) -> Result<()>; + /// Generate hashes for an arbitrary file by providing a local path to the file. + fn generate_hashes_for_path(&self, file: PathBuf) -> Result<HashResponse>; + /// Generate hashes for an arbitrary file by sending the file. + fn generate_hashes_for_file(&self, file: PathBuf) -> Result<HashResponse>; +} + +pub trait ImportingAndEditingUrls { + fn get_url_files( + &self, + url: &str, + doublecheck_file_system: Option<bool>, + ) -> Result<FilesUrlResponse>; +} |
