wip
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user