From 4f73ec6efa045fea4aa312e3bec89963c49362ad Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 3 Nov 2026 13:02:51 -0500 Subject: [PATCH 01/12] Adding ledger module --- src/ledger/mod.rs | 8 ++++++++ src/lib.rs | 1 + 2 files changed, 9 insertions(+) create mode 100644 src/ledger/mod.rs diff --git a/src/ledger/mod.rs b/src/ledger/mod.rs new file mode 100644 index 0000000..53cb12c --- /dev/null +++ b/src/ledger/mod.rs @@ -0,0 +1,8 @@ + +pub struct SongEvent { + pub id: uuid::Uuid, + pub song_id: uuid::Uuid, + pub user_id: uuid::Uuid, + pub event_type: String, + pub event_time: time::OffsetDateTime +} diff --git a/src/lib.rs b/src/lib.rs index f4fcab5..88bb098 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ pub mod access_level; pub mod album; pub mod constants; pub mod coverart; +pub mod ledger; pub mod login_result; pub mod song; pub mod token; -- 2.47.3 From a960c7d2990e25f6b79c427751adfc4c634489fb Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 3 Nov 2026 13:05:48 -0500 Subject: [PATCH 02/12] Adding event type constants --- src/ledger/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ledger/mod.rs b/src/ledger/mod.rs index 53cb12c..6646749 100644 --- a/src/ledger/mod.rs +++ b/src/ledger/mod.rs @@ -6,3 +6,6 @@ pub struct SongEvent { pub event_type: String, pub event_time: time::OffsetDateTime } + +pub const SONG_EVENT_TYPE_PLAY: &str = "PLAY"; +pub const SONG_EVENT_TYPE_PAUSE: &str = "PAUSE"; -- 2.47.3 From a2c4980277a47e12b5222204108ef6a8f9296231 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 4 Nov 2026 14:50:40 -0500 Subject: [PATCH 03/12] Adding method to validate event_type of SongEvent --- src/ledger/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ledger/mod.rs b/src/ledger/mod.rs index 6646749..808479e 100644 --- a/src/ledger/mod.rs +++ b/src/ledger/mod.rs @@ -7,5 +7,23 @@ pub struct SongEvent { pub event_time: time::OffsetDateTime } +impl SongEvent { + pub fn is_event_type_valid(&self) -> bool { + match self.event_type.as_str() { + SONG_EVENT_TYPE_PLAY => { + true + }, + SONG_EVENT_TYPE_PAUSE => { + true + }, + _ => { + false + } + } + } +} + +/// Song Event Type - Play pub const SONG_EVENT_TYPE_PLAY: &str = "PLAY"; +/// Song Event Type - PAUSE pub const SONG_EVENT_TYPE_PAUSE: &str = "PAUSE"; -- 2.47.3 From 4bf850ae157c5597efa67c4e1d94716a89b3f5a7 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 4 Nov 2026 14:51:21 -0500 Subject: [PATCH 04/12] Code formatting --- src/ledger/mod.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/ledger/mod.rs b/src/ledger/mod.rs index 808479e..0f9fa9c 100644 --- a/src/ledger/mod.rs +++ b/src/ledger/mod.rs @@ -1,24 +1,17 @@ - pub struct SongEvent { pub id: uuid::Uuid, pub song_id: uuid::Uuid, pub user_id: uuid::Uuid, pub event_type: String, - pub event_time: time::OffsetDateTime + pub event_time: time::OffsetDateTime, } impl SongEvent { pub fn is_event_type_valid(&self) -> bool { match self.event_type.as_str() { - SONG_EVENT_TYPE_PLAY => { - true - }, - SONG_EVENT_TYPE_PAUSE => { - true - }, - _ => { - false - } + SONG_EVENT_TYPE_PLAY => true, + SONG_EVENT_TYPE_PAUSE => true, + _ => false, } } } -- 2.47.3 From 8d2ed157d5245ddadf8a2d103965593289067050 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 4 Nov 2026 14:53:00 -0500 Subject: [PATCH 05/12] Warning fixes --- src/ledger/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ledger/mod.rs b/src/ledger/mod.rs index 0f9fa9c..3e4c6b0 100644 --- a/src/ledger/mod.rs +++ b/src/ledger/mod.rs @@ -8,11 +8,10 @@ pub struct SongEvent { impl SongEvent { pub fn is_event_type_valid(&self) -> bool { - match self.event_type.as_str() { - SONG_EVENT_TYPE_PLAY => true, - SONG_EVENT_TYPE_PAUSE => true, - _ => false, - } + matches!( + self.event_type.as_str(), + SONG_EVENT_TYPE_PLAY | SONG_EVENT_TYPE_PAUSE + ) } } -- 2.47.3 From 36781f2487d376dda3c517c49e850c11b4c9fa05 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 4 Nov 2026 14:53:42 -0500 Subject: [PATCH 06/12] cargo update --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 889b8a1..4b0a9b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,9 +43,9 @@ checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "cc" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0" +checksum = "375989decec1a0fa424442bed520fa12ede43a48475ce8c7417d2c69b32b5f6b" dependencies = [ "find-msvc-tools", "shlex", @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055" +checksum = "5f97d3416d5337d15c4b0d78c8c91df922ca143f57ec20e2d1c188333047ef04" dependencies = [ "cfg-if", ] @@ -285,9 +285,9 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "openssl" -version = "0.10.81" +version = "0.10.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" +checksum = "4de8111e94a56adca7ebfe6c365b6d42f99deb69b74b6becacd4204e2f193aa2" dependencies = [ "bitflags", "cfg-if", @@ -310,9 +310,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.117" +version = "0.9.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" +checksum = "19c413d6ec9ebaf5e1c829d355cb3e9f783778d700f135be0921d52fce3c60ae" dependencies = [ "cc", "libc", -- 2.47.3 From 7b7d6a29f62d7a3e6dd64bfed9340a23ef35583d Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 4 Nov 2026 14:54:02 -0500 Subject: [PATCH 07/12] bump: simodels --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b0a9b2..86f508f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -486,7 +486,7 @@ checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" [[package]] name = "simodels" -version = "0.11.8" +version = "0.11.9" dependencies = [ "josekit", "rand", diff --git a/Cargo.toml b/Cargo.toml index 025fa74..cf72992 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simodels" -version = "0.11.8" +version = "0.11.9" edition = "2024" rust-version = "1.95" description = "Models used for the soaricarus project" -- 2.47.3 From f31178b3f0052ca4782f12e22061902e5eab1895 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 4 Nov 2026 14:56:47 -0500 Subject: [PATCH 08/12] Adding date_created --- src/ledger/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ledger/mod.rs b/src/ledger/mod.rs index 3e4c6b0..441d5b6 100644 --- a/src/ledger/mod.rs +++ b/src/ledger/mod.rs @@ -3,7 +3,8 @@ pub struct SongEvent { pub song_id: uuid::Uuid, pub user_id: uuid::Uuid, pub event_type: String, - pub event_time: time::OffsetDateTime, + pub event_time: Option, + pub date_created: Option, } impl SongEvent { -- 2.47.3 From fc5644bf370c569b0e32e01ac8a9e8715e512c31 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 4 Nov 2026 16:10:29 -0500 Subject: [PATCH 09/12] Adding traits to SongEvent --- src/ledger/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ledger/mod.rs b/src/ledger/mod.rs index 441d5b6..37cf005 100644 --- a/src/ledger/mod.rs +++ b/src/ledger/mod.rs @@ -1,3 +1,4 @@ +#[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)] pub struct SongEvent { pub id: uuid::Uuid, pub song_id: uuid::Uuid, -- 2.47.3 From 18a7981d82445275b590243a26548e754494a500 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 4 Nov 2026 18:40:29 -0500 Subject: [PATCH 10/12] Updating macros --- src/ledger/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ledger/mod.rs b/src/ledger/mod.rs index 37cf005..1d7b420 100644 --- a/src/ledger/mod.rs +++ b/src/ledger/mod.rs @@ -4,7 +4,9 @@ pub struct SongEvent { pub song_id: uuid::Uuid, pub user_id: uuid::Uuid, pub event_type: String, + #[serde(with = "time::serde::rfc3339::option")] pub event_time: Option, + #[serde(with = "time::serde::rfc3339::option")] pub date_created: Option, } -- 2.47.3 From 43cc4defbbe085c3cdb13e4b4a704d12738d2d7b Mon Sep 17 00:00:00 2001 From: phoenix Date: Thu, 5 Nov 2026 15:03:11 -0500 Subject: [PATCH 11/12] Adding features --- Cargo.toml | 16 ++++++++++++++++ src/access_level.rs | 16 +++++++++------- src/constants.rs | 12 ++++++++++++ src/ledger/mod.rs | 8 ++------ src/token.rs | 2 +- 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cf72992..1cf077d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,5 +15,21 @@ uuid = { version = "1.29.0", features = ["v4", "serde"] } josekit = { version = "0.10.3" } utoipa = { version = "6.0.0", features = ["uuid", "time"] } +[features] +default = ["full"] +full = ["access_level", "album", "constants", "coverart", "ledger", "login_result", "song", "token", "types", "user", "util"] +auth = ["constants", "login_result", "token", "user"] +access_level = ["constants"] +album = [] +constants = [] +coverart = ["constants", "types"] +ledger = ["constants", "song", "types", "user"] +login_result = ["constants", "token", "user"] +song = ["constants", "types"] +token = [] +types = [] +user = [] +util = [] + [dev-dependencies] tempfile = { version = "3.27.0" } diff --git a/src/access_level.rs b/src/access_level.rs index 35901f2..6ad2a8e 100644 --- a/src/access_level.rs +++ b/src/access_level.rs @@ -2,6 +2,8 @@ use std::default::Default; use serde::{Deserialize, Serialize}; +const DEFAULT_ACCESS_LEVEL: &str = super::constants::access_level::PUBLIC; + #[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)] pub struct AccessLevel { pub id: uuid::Uuid, @@ -13,8 +15,8 @@ impl Default for AccessLevel { fn default() -> Self { AccessLevel { id: uuid::Uuid::nil(), - level: String::new(), - song_id: uuid::Uuid::new_v4(), + level: DEFAULT_ACCESS_LEVEL.to_string(), + song_id: uuid::Uuid::nil(), } } } @@ -22,16 +24,16 @@ impl Default for AccessLevel { pub fn default_level() -> AccessLevel { AccessLevel { id: uuid::Uuid::nil(), - level: String::from("Public"), - song_id: uuid::Uuid::new_v4(), + level: DEFAULT_ACCESS_LEVEL.to_string(), + song_id: uuid::Uuid::nil(), } } pub fn private_level() -> AccessLevel { AccessLevel { - id: uuid::Uuid::new_v4(), - level: String::from("Private"), - song_id: uuid::Uuid::new_v4(), + id: uuid::Uuid::nil(), + level: super::constants::access_level::PRIVATE.to_string(), + song_id: uuid::Uuid::nil(), } } diff --git a/src/constants.rs b/src/constants.rs index 4432a85..8fb3e8e 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -13,6 +13,18 @@ pub mod file_extensions { } } +pub mod song_event { + /// Song Event Type - Play + pub const SONG_EVENT_TYPE_PLAY: &str = "PLAY"; + /// Song Event Type - PAUSE + pub const SONG_EVENT_TYPE_PAUSE: &str = "PAUSE"; +} + +pub mod access_level { + pub const PUBLIC: &str = "PUBLIC"; + pub const PRIVATE: &str = "PRIVATE"; +} + pub mod error { pub const DIRECTORY_NOT_INITIALIZED: &str = "Directory has not been initialized"; pub const FILENAME_NOT_INITIALIZED: &str = "Filename has not bee initialized"; diff --git a/src/ledger/mod.rs b/src/ledger/mod.rs index 1d7b420..933f819 100644 --- a/src/ledger/mod.rs +++ b/src/ledger/mod.rs @@ -14,12 +14,8 @@ impl SongEvent { pub fn is_event_type_valid(&self) -> bool { matches!( self.event_type.as_str(), - SONG_EVENT_TYPE_PLAY | SONG_EVENT_TYPE_PAUSE + super::constants::song_event::SONG_EVENT_TYPE_PLAY + | super::constants::song_event::SONG_EVENT_TYPE_PAUSE ) } } - -/// Song Event Type - Play -pub const SONG_EVENT_TYPE_PLAY: &str = "PLAY"; -/// Song Event Type - PAUSE -pub const SONG_EVENT_TYPE_PAUSE: &str = "PAUSE"; diff --git a/src/token.rs b/src/token.rs index 3e013a5..79e8882 100644 --- a/src/token.rs +++ b/src/token.rs @@ -111,7 +111,7 @@ pub struct TokenResource { pub id: uuid::Uuid, } -pub const TOKEN_TYPE: &str = "JWT"; +const TOKEN_TYPE: &str = "JWT"; pub fn create_token( key: &String, -- 2.47.3 From 1d433831a25d37b2bb235f28373ffc164a1dfa6d Mon Sep 17 00:00:00 2001 From: phoenix Date: Thu, 5 Nov 2026 15:17:01 -0500 Subject: [PATCH 12/12] Making it available --- src/constants.rs | 4 ++++ src/token.rs | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index 8fb3e8e..cde62f2 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -25,6 +25,10 @@ pub mod access_level { pub const PRIVATE: &str = "PRIVATE"; } +pub mod token { + pub const TOKEN_TYPE: &str = "JWT"; +} + pub mod error { pub const DIRECTORY_NOT_INITIALIZED: &str = "Directory has not been initialized"; pub const FILENAME_NOT_INITIALIZED: &str = "Filename has not bee initialized"; diff --git a/src/token.rs b/src/token.rs index 79e8882..216cd7a 100644 --- a/src/token.rs +++ b/src/token.rs @@ -111,15 +111,13 @@ pub struct TokenResource { pub id: uuid::Uuid, } -const TOKEN_TYPE: &str = "JWT"; - pub fn create_token( key: &String, token_resource: &TokenResource, duration: time::Duration, ) -> Result<(String, i64), josekit::JoseError> { let mut header = josekit::jws::JwsHeader::new(); - header.set_token_type(TOKEN_TYPE); + header.set_token_type(super::constants::token::TOKEN_TYPE); let mut payload = josekit::jwt::JwtPayload::new(); let message = &token_resource.message; -- 2.47.3