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
use crate::Profile;


#[derive(Debug)]
pub enum ErrorStorage {
    NoPath,
    NotDir,
    CannotCreate(std::io::Error),
}


#[derive(Debug)]
pub enum Error {
    CannotLoad(Profile, std::io::Error),
    CannotSave(Profile, std::io::Error),

    CredentialsNoPath,
    CredentialsNotFound,
    CredentialsCannotRemove(std::io::Error),

    ProfileExists(Profile),
    ProfileNotFound(Profile),
    ProfileCannotRemove(Profile, std::io::Error),

    Storage(ErrorStorage),
}

impl From<ErrorStorage> for Error {
    fn from(err: ErrorStorage) -> Self { Self::Storage(err) }
}


#[derive(Debug)]
pub enum Success {
    List(Vec<Profile>),
    Saved(Profile),
    Loaded(Profile),
    Cleared,
    Removed {
        removed: Vec<Profile>,
        errors: Vec<Error>,
    },
}