OneLauncher-Cracked/packages/oneclient_db/src/models/artifact.rs

63 lines
1.2 KiB
Rust

use serde::{Deserialize, Serialize};
use sqlx::FromRow;
#[derive(Debug, Clone, FromRow)]
pub struct ArtifactRow {
pub hash: String,
pub content_type: i64,
pub path: String,
pub file_name: String,
pub size_bytes: Option<i64>,
}
#[derive(Debug, Clone, FromRow)]
pub struct ProviderReleaseRow {
pub provider: i64,
pub project_id: String,
pub version_id: String,
pub hash: String,
pub display_name: String,
pub display_version: String,
pub published_at: Option<String>,
pub mc_versions: String,
pub mc_loaders: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[repr(i64)]
pub enum SeenStatus {
New = 0,
Updated = 1,
#[default]
Seen = 2,
}
impl SeenStatus {
pub fn as_i64(self) -> i64 {
self as i64
}
pub fn from_repr(value: i64) -> Option<Self> {
match value {
0 => Some(Self::New),
1 => Some(Self::Updated),
2 => Some(Self::Seen),
_ => None,
}
}
}
#[derive(Debug, Clone, FromRow)]
pub struct ClusterArtifactRow {
pub cluster_id: i64,
pub hash: String,
pub cluster_file_name: String,
pub enabled: i64,
pub seen_status: i64,
}
impl ClusterArtifactRow {
pub fn status(&self) -> SeenStatus {
SeenStatus::from_repr(self.seen_status).unwrap_or_default()
}
}