cargo_user/
errors.rs

1use std::path::PathBuf;
2use crate::Profile;
3
4
5#[derive(Debug)]
6pub enum ErrorStorage {
7    NoPath,
8    NotDir,
9    CannotCreate(std::io::Error),
10}
11
12
13#[derive(Debug)]
14pub enum Error {
15    CannotLoad(Profile, std::io::Error),
16    CannotSave(Profile, std::io::Error),
17
18    CredentialsNoPath,
19    CredentialsNotFound,
20    CredentialsCannotRead(std::io::Error),
21    CredentialsCannotRemove(std::io::Error),
22
23    ProfileExists(Profile),
24    ProfileNotFound(Profile),
25    ProfileCannotRead(Profile, std::io::Error),
26    ProfileCannotRemove(Profile, std::io::Error),
27    ProfileCannotRename(Profile, Profile, std::io::Error),
28
29    Storage(ErrorStorage),
30}
31
32impl From<ErrorStorage> for Error {
33    fn from(err: ErrorStorage) -> Self { Self::Storage(err) }
34}
35
36
37#[derive(Debug)]
38pub enum Success {
39    List(Vec<Profile>),
40    Current(Vec<Profile>),
41    CurrentNone,
42    Found(PathBuf),
43    Saved(Profile),
44    Loaded(Profile),
45    Cleared,
46    Renamed(Profile, Profile),
47    Removed {
48        removed: Vec<Profile>,
49        errors: Vec<Error>,
50    },
51}