summaryrefslogtreecommitdiffstats
path: root/src/launcher/jre/manifest.rs
blob: 41780d0647660d4f76ccb25e0de06824b3a316f8 (plain) (blame)
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
use std::collections::HashMap;
use indexmap::IndexMap;
use serde::Deserialize;
use crate::version::DownloadInfo;

#[derive(Debug, Deserialize)]
pub struct Availability {
    pub group: u32,   // unknown meaning
    pub progress: u32 // unknown meaning
}

#[derive(Debug, Deserialize)]
pub struct Version {
    pub name: String,
    pub version: String
}

#[derive(Debug, Deserialize)]
pub struct JavaRuntimeInfo {
    // I don't see how half of this information is useful with how the JRE system currently functions -figboot
    pub availability: Availability,
    pub manifest: DownloadInfo,
    //pub version: Version
}

pub type JavaRuntimesManifest = HashMap<String, HashMap<String, Vec<JavaRuntimeInfo>>>;

#[derive(Debug, Deserialize)]
pub struct FileDownloads {
    lzma: Option<DownloadInfo>,
    raw: DownloadInfo
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "lowercase", tag = "type")]
pub enum JavaRuntimeFile {
    File {
        #[serde(default)]
        executable: bool,
        downloads: FileDownloads
    },
    Directory,
    Link {
        target: String
    }
}

impl JavaRuntimeFile {
    pub fn is_file(&self) -> bool {
        matches!(*self, JavaRuntimeFile::File { .. })
    }

    pub fn is_directory(&self) -> bool {
        matches!(*self, JavaRuntimeFile::Directory)
    }

    pub fn is_link(&self) -> bool {
        matches!(*self, JavaRuntimeFile::Link { .. })
    }
}

#[derive(Debug, Deserialize)]
pub struct JavaRuntimeManifest {
    pub files: IndexMap<String, JavaRuntimeFile>
}