summaryrefslogtreecommitdiffhomepage
path: root/test/test-rpc/src/package.rs
blob: 36b7f479ad3cea6ac07d23cb290445b3c918d627 (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
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

#[derive(thiserror::Error, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub enum Error {
    #[error("Failed open file for writing")]
    OpenFile,

    #[error("Failed to write downloaded file to disk")]
    WriteFile,

    #[error("Failed to convert download to bytes")]
    ToBytes,

    #[error("Failed to convert download to bytes")]
    RequestFailed,

    #[error("Cannot parse version")]
    InvalidVersion,

    #[error("Failed to run package installer")]
    RunApp,

    #[error("Failed to create temporary uninstaller")]
    CreateTempUninstaller,

    #[error("Installer or uninstaller failed due to an unknown error: {0}")]
    InstallerFailed(i32),

    #[error("Installer or uninstaller failed due to a signal")]
    InstallerFailedSignal,

    #[error("Unrecognized OS: {0}")]
    UnknownOs(String),
}

pub type Result<T> = std::result::Result<T, Error>;

#[derive(Debug, Deserialize, Serialize)]
pub struct Package {
    pub path: PathBuf,
}