summaryrefslogtreecommitdiff
path: root/src/types.rs
blob: d13a8aae54af936fd0168645b00aedf8ea3c17e1 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use musli::{Decode, Encode};
use thiserror::Error;

#[derive(Error, Debug)]
pub enum HydrusError {
    #[error("failed to connect to Hydrus")]
    NetworkError(ureq::Error),
    #[error("failed to deserialize data")]
    DeserializeError(musli::Error),
}

impl Into

#[derive(Decode, Encode, PartialEq, Debug)]
#[repr(u8)]
pub enum HydrusPermissions {
    ImportAndEditURLs = 0,
    ImportAndEditFiles,
    EditFileTags,
    SearchAndFetchFiles,
    ManagePages,
    ManageCookiesAndHeaders,
    ManageDatabase,
    EditFileNotes,
    EditFileRelationships,
    EditFileRatings,
    ManagePopups,
    EditFileTimes,
    CommitPending,
    SeeLocalPaths,
}

#[derive(Decode)]
struct AccessKey {
    access_key: String,
}

#[derive(Decode)]
struct SessionKey {
    session_key: String,
}

#[derive(Decode)]
pub struct KeyInfo {
    name: String,
    permits_everything: bool,
    basic_permissions: Vec<HydrusPermissions>,
    human_permissions: String,
}

#[derive(Decode, Encode, PartialEq, Debug)]
#[repr(u8)]
pub enum ServiceType {
    TagRepository = 0,
    FileRepository,
    LocalFileDomain,
    LocalTagDomain = 5,
    NumericalRating,
    BoolRating,
    AllKnownTags = 10,
    AllKnownFiles,
    LocalBooru,
    IPFS,
    Trash,
    AllLocalFiles,
    FileNotes = 17,
    ClientAPI,
    DeletedFromAnywhere,
    LocalUpdates,
    AllMyFiles,
    IncDecRating,
    ServerAdmin = 99,
}

#[derive(Decode)]
pub struct Service {
    name: String,
    #[musli(default)]
    service_key: String,
    servicetype: ServiceType,
    type_pretty: String,
}