cobble_core/minecraft/fabric/
loader_summary.rs

1use crate::consts;
2use serde::{Deserialize, Serialize};
3
4/// An entry in the fabric loader manifest representing a single version.
5#[cfg_attr(doc_cfg, doc(cfg(feature = "fabric")))]
6#[derive(Clone, Debug, Deserialize, Serialize)]
7pub struct FabricLoaderSummary {
8    /// Information about the loader.
9    pub loader: FabricLoaderInfo,
10    /// Information about the intermediary.
11    pub intermediary: FabricIntermediaryInfo,
12}
13
14impl FabricLoaderSummary {
15    /// Gets the manifest from fabric servers.
16    pub async fn fetch_manifest(game_version: &str) -> reqwest::Result<Vec<Self>> {
17        let url = Self::version_url(game_version);
18
19        reqwest::get(url)
20            .await?
21            .error_for_status()?
22            .json::<Vec<Self>>()
23            .await
24    }
25
26    fn version_url(game_version: &str) -> String {
27        format!(
28            "{}/versions/loader/{}",
29            consts::FABRIC_BASE_V2_URL,
30            game_version
31        )
32    }
33}
34
35/// Information about the loader.
36#[cfg_attr(doc_cfg, doc(cfg(feature = "fabric")))]
37#[derive(Clone, Debug, Deserialize, Serialize)]
38pub struct FabricLoaderInfo {
39    /// Separator
40    pub separator: String,
41    /// Build
42    pub build: i32,
43    /// Maven
44    pub maven: String,
45    /// Version
46    pub version: String,
47    /// Stable
48    pub stable: bool,
49}
50
51/// Information about the intermediary.
52#[cfg_attr(doc_cfg, doc(cfg(feature = "fabric")))]
53#[derive(Clone, Debug, Deserialize, Serialize)]
54pub struct FabricIntermediaryInfo {
55    /// Maven
56    pub maven: String,
57    /// Version
58    pub version: String,
59    /// Stable
60    pub stable: bool,
61}