cobble-core 1.2.0

Library for managing, installing and launching Minecraft instances and more.
Documentation
use crate::minecraft::models::{VersionData, VersionType};
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;

/// Summary of a version that is found in the version manifest.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct VersionSummary {
    /// The version ID.
    /// Usually this is the version number for releases.
    pub id: String,
    /// The type of version this is.
    /// Release, Snapshot, Beta or Alpha.
    #[serde(rename = "type")]
    pub _type: VersionType,
    /// The URL of the version data JSON.
    pub url: String,
    /// Release time
    #[serde(with = "time::serde::rfc3339")]
    pub time: OffsetDateTime,
    /// Release time
    #[serde(alias = "releaseTime", with = "time::serde::rfc3339")]
    pub release_time: OffsetDateTime,
}

impl VersionSummary {
    /// Gets the version data itself from Minecraft servers.
    pub async fn fetch_data(&self) -> reqwest::Result<VersionData> {
        reqwest::get(&self.url)
            .await?
            .error_for_status()?
            .json()
            .await
    }
}