diff --git a/Cargo.toml b/Cargo.toml index 8ba6420..a55bb28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,4 @@ edition = "2024" chrono = { version = "0.4.41", features = ["serde"] } serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.141" +uuid = { version = "1.17.0", features = ["serde", "v4"] } diff --git a/src/log.rs b/src/log.rs index e7f1ec0..5d76bf0 100644 --- a/src/log.rs +++ b/src/log.rs @@ -1,8 +1,10 @@ use chrono::{DateTime, Local}; use serde::{Deserialize, Serialize}; +use uuid::Uuid; #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)] pub struct Item { + id: Uuid, content: String, created: DateTime, modified: DateTime, @@ -17,12 +19,17 @@ impl Item { self.content = content; self.modified = Local::now(); } + + pub fn id(&self) -> String { + self.id.to_string() + } } impl Default for Item { fn default() -> Self { let now = Local::now(); Self { + id: Uuid::new_v4(), content: String::new(), created: now, modified: now,