This commit is contained in:
Timur Gordon
2025-10-29 16:52:33 +01:00
parent 03e5615541
commit 87c556df7a
76 changed files with 10186 additions and 47 deletions

View File

@@ -6,7 +6,7 @@ use time::OffsetDateTime;
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
pub struct BaseData {
/// Unique ID (auto-generated or user-assigned)
pub id: String,
pub id: u32,
/// Namespace this object belongs to
pub ns: String,
@@ -27,12 +27,25 @@ pub struct BaseData {
}
impl BaseData {
/// Create new base data with generated UUID
pub fn new(ns: String) -> Self {
/// Create new base data with ID 0 (no namespace required)
pub fn new() -> Self {
let now = OffsetDateTime::now_utc();
Self {
id: uuid::Uuid::new_v4().to_string(),
ns,
id: 0,
ns: String::new(),
created_at: now,
modified_at: now,
mime: None,
size: None,
}
}
/// Create new base data with namespace
pub fn with_ns(ns: impl ToString) -> Self {
let now = OffsetDateTime::now_utc();
Self {
id: 0,
ns: ns.to_string(),
created_at: now,
modified_at: now,
mime: None,
@@ -41,7 +54,7 @@ impl BaseData {
}
/// Create new base data with specific ID
pub fn with_id(id: String, ns: String) -> Self {
pub fn with_id(id: u32, ns: String) -> Self {
let now = OffsetDateTime::now_utc();
Self {
id,
@@ -73,6 +86,6 @@ impl BaseData {
impl Default for BaseData {
fn default() -> Self {
Self::new(String::from("default"))
Self::new()
}
}