mc_launchermeta/version/
library.rs

1////////////////////////////////////////////////////////////////////////////////
2// Copyright (c) 2023. Rob Bailey                                              /
3// This Source Code Form is subject to the terms of the Mozilla Public         /
4// License, v. 2.0. If a copy of the MPL was not distributed with this         /
5// file, You can obtain one at https://mozilla.org/MPL/2.0/.                   /
6////////////////////////////////////////////////////////////////////////////////
7
8//! Information about the libraries used by the game
9
10use std::collections::BTreeMap;
11
12use serde::{Deserialize, Serialize};
13
14use crate::version::rule::Rule;
15
16#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
17#[serde(deny_unknown_fields)]
18pub struct Artifact {
19    pub path: String,
20    pub sha1: String,
21    pub size: u64,
22    pub url: String,
23}
24
25#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
26#[serde(deny_unknown_fields)]
27pub struct Downloads {
28    #[serde(default)]
29    pub artifact: Option<Artifact>,
30    #[serde(default)]
31    pub classifiers: Option<BTreeMap<String, Artifact>>,
32}
33
34#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
35pub struct Natives {
36    pub linux: Option<String>,
37    pub osx: Option<String>,
38    pub windows: Option<String>,
39}
40
41pub type Extract = BTreeMap<String, Vec<String>>;
42
43#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
44#[serde(deny_unknown_fields)]
45pub struct Library {
46    /// A list of artifacts to potentially download for the library
47    pub downloads: Option<Downloads>,
48    /// The name of the library, in the format `group:name:version`
49    pub name: String,
50    /// Information on how to extract the library.
51    ///
52    /// This is used for natives, and is a map of the files to extract to the directories to extract
53    #[serde(default)]
54    pub extract: Option<Extract>,
55    /// Information on natives for the version
56    ///
57    /// This was used in older versions of the format
58    #[serde(default)]
59    pub natives: Option<Natives>,
60    #[serde(default)]
61    pub rules: Option<Vec<Rule>>,
62}