use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use url::Url;
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AdoptiumAvailableReleases {
pub available_lts_releases: Vec<u32>,
pub available_releases: Vec<u32>,
pub most_recent_feature_release: u32,
pub most_recent_feature_version: u32,
pub most_recent_lts: u32,
pub tip_version: u32,
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum AdoptiumJvmImpl {
#[default]
HotSpot,
}
impl AdoptiumJvmImpl {
pub const fn as_str(self) -> &'static str {
match self {
AdoptiumJvmImpl::HotSpot => "hotspot",
}
}
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum AdoptiumReleaseType {
#[default]
Ga,
Ea,
}
impl AdoptiumReleaseType {
pub const fn as_str(self) -> &'static str {
match self {
AdoptiumReleaseType::Ga => "ga",
AdoptiumReleaseType::Ea => "ea",
}
}
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum AdoptiumImageType {
#[default]
Jdk,
Jre,
DebugImage,
StaticLibs,
Sources,
TestImage,
}
impl AdoptiumImageType {
pub const fn as_str(self) -> &'static str {
match self {
AdoptiumImageType::Jdk => "jdk",
AdoptiumImageType::Jre => "jre",
AdoptiumImageType::DebugImage => "debugimage",
AdoptiumImageType::StaticLibs => "staticlibs",
AdoptiumImageType::Sources => "sources",
AdoptiumImageType::TestImage => "testimage",
}
}
}
#[derive(Clone, Debug, Default, Serialize)]
pub struct AdoptiumAssetFilter {
pub os: Option<String>,
pub architecture: Option<String>,
pub image_type: Option<AdoptiumImageType>,
pub vendor: Option<String>,
pub page: Option<u32>,
pub page_size: Option<u32>,
}
impl AdoptiumAssetFilter {
pub fn new() -> Self {
Self::default()
}
pub fn os(mut self, os: impl Into<String>) -> Self {
self.os = Some(os.into());
self
}
pub fn architecture(mut self, arch: impl Into<String>) -> Self {
self.architecture = Some(arch.into());
self
}
pub fn image_type(mut self, image_type: AdoptiumImageType) -> Self {
self.image_type = Some(image_type);
self
}
pub fn vendor(mut self, vendor: impl Into<String>) -> Self {
self.vendor = Some(vendor.into());
self
}
pub fn page(mut self, page: u32) -> Self {
self.page = Some(page);
self
}
pub fn page_size(mut self, page_size: u32) -> Self {
self.page_size = Some(page_size);
self
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AdoptiumBinaryAsset {
pub binary: AdoptiumBinary,
pub release_name: String,
pub version: AdoptiumVersionData,
#[serde(default)]
pub vendor: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AdoptiumRelease {
pub id: String,
pub release_name: String,
pub release_type: AdoptiumReleaseType,
pub timestamp: DateTime<Utc>,
#[serde(default)]
pub binaries: Vec<AdoptiumBinary>,
pub version_data: AdoptiumVersionData,
#[serde(default)]
pub release_link: Option<Url>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AdoptiumBinary {
pub architecture: String,
pub os: String,
pub image_type: String,
pub jvm_impl: String,
pub package: AdoptiumPackage,
#[serde(default)]
pub download_count: Option<u64>,
#[serde(default)]
pub updated_at: Option<DateTime<Utc>>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AdoptiumPackage {
pub checksum: String,
pub link: Url,
pub name: String,
pub size: u64,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AdoptiumVersionData {
pub major: u32,
#[serde(default)]
pub minor: u32,
#[serde(default)]
pub security: u32,
#[serde(default)]
pub build: u32,
pub semver: String,
#[serde(default)]
pub openjdk_version: Option<String>,
}