summaryrefslogtreecommitdiff
path: root/src/traits.rs
blob: d8f68f2584d85fbc2c3f711b683ac111c63d45d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::{collections::HashMap, path::PathBuf};

use crate::types::*;
use async_trait::async_trait;

type Result<T> = std::result::Result<T, HydrusError>;

#[async_trait]
pub trait AccessManagement {
    async fn request_new_permissions(
        &self,
        name: &str,
        permissions: &[HydrusPermissions],
    ) -> Result<String>;

    async fn get_session_key(&self) -> Result<String>;

    async fn verify_access_key(&self, key: &str) -> Result<KeyInfo>;

    async fn get_service_name(&self, name: &str) -> Result<Service>;

    async fn get_service_key(&self, key: &str) -> Result<Service>;

    async fn get_services(&self) -> Result<HashMap<String, Service>>;
}

#[async_trait]
pub trait ImportingAndDeletingFiles {
    async fn add_file_via_path(
        &self,
        path: &str,
        delete: Option<bool>,
        domains: Option<FileDomain>,
    ) -> Result<FileAddResponse>;

    async fn add_file_via_file(&self, file: PathBuf) -> Result<FileAddResponse>;
}