use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, PartialOrd, Hash)]
pub enum PrimaryChannel {
Live,
ZLive,
ZCanary,
ZIntegration,
}
impl ToString for PrimaryChannel {
fn to_string(&self) -> String {
let str = match self {
PrimaryChannel::Live => "LIVE",
PrimaryChannel::ZLive => "zlive",
PrimaryChannel::ZCanary => "zcanary",
PrimaryChannel::ZIntegration => "zintegration",
};
str.to_owned()
}
}
pub const PRIMARY_CHANNELS: [PrimaryChannel; 4] = [
PrimaryChannel::Live,
PrimaryChannel::ZLive,
PrimaryChannel::ZCanary,
PrimaryChannel::ZIntegration,
];
#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, PartialOrd, Hash)]
pub enum BinaryType {
WindowsPlayer,
WindowsStudio,
WindowsStudio64,
MacPlayer,
MacStudio,
}
impl ToString for BinaryType {
fn to_string(&self) -> String {
let str = match self {
BinaryType::WindowsPlayer => "WindowsPlayer",
BinaryType::WindowsStudio => "WindowsStudio",
BinaryType::WindowsStudio64 => "WindowsStudio64",
BinaryType::MacPlayer => "MacPlayer",
BinaryType::MacStudio => "MacStudio",
};
str.to_owned()
}
}
pub const BINARY_TYPES: [BinaryType; 5] = [
BinaryType::WindowsPlayer,
BinaryType::WindowsStudio,
BinaryType::WindowsStudio64,
BinaryType::MacPlayer,
BinaryType::MacStudio,
];
#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, PartialOrd, Hash)]
pub enum RecordType {
LatestDeploy,
DeployHistory,
}
impl ToString for RecordType {
fn to_string(&self) -> String {
let str = match self {
RecordType::LatestDeploy => "LatestDeploy.json",
RecordType::DeployHistory => "DeployHistory.json",
};
str.to_owned()
}
}
#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, PartialOrd, Hash)]
pub enum DeploymentSpace {
Global,
Luobu,
}
impl DeploymentSpace {
pub fn get_roblox_domain(&self) -> &str {
match self {
Self::Global => "roblox.com",
Self::Luobu => "roblox.qq.com",
}
}
pub fn get_cdn_domain(&self) -> &str {
match self {
Self::Global => "rbxcdn.com",
Self::Luobu => "rbxcdn.qq.com",
}
}
pub fn get_client_version_url(&self) -> String {
format!(
"https://clientsettings.{}/v2/client-version",
self.get_roblox_domain()
)
}
}
impl ToString for DeploymentSpace {
fn to_string(&self) -> String {
let str = match self {
DeploymentSpace::Global => "Global",
DeploymentSpace::Luobu => "Luobu",
};
str.to_string()
}
}
pub type DeployHistory = BTreeMap<u64, DeploymentRecord>;
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DeploymentRecord {
pub client_version: String,
pub bootstrapper_version: String,
pub major_rev: u32,
pub version: u32,
pub patch: u32,
pub change_list: u64, }
impl ToString for DeploymentRecord {
fn to_string(&self) -> String {
return format!(
"{}.{}.{}.{}",
self.major_rev, self.version, self.patch, self.change_list
);
}
}