Compare commits

...
Author SHA1 Message Date
phoenix 43cc4defbb Adding features
Release Tagging / release (pull_request) Successful in 16s
simodels Build / Check (pull_request) Successful in 17s
simodels Build / build (pull_request) Successful in 18s
simodels Build / Clippy (pull_request) Successful in 18s
simodels Build / Rustfmt (pull_request) Successful in 23s
simodels Build / Test Suite (pull_request) Successful in 28s
2026-11-05 15:03:11 -05:00
phoenix 18a7981d82 Updating macros
simodels Build / Clippy (pull_request) Successful in 15s
simodels Build / Check (pull_request) Successful in 21s
simodels Build / build (pull_request) Successful in 20s
Release Tagging / release (pull_request) Successful in 23s
simodels Build / Rustfmt (pull_request) Successful in 21s
simodels Build / Test Suite (pull_request) Successful in 25s
2026-11-04 18:40:29 -05:00
phoenix fc5644bf37 Adding traits to SongEvent
simodels Build / Clippy (pull_request) Successful in 17s
Release Tagging / release (pull_request) Successful in 23s
simodels Build / build (pull_request) Successful in 20s
simodels Build / Check (pull_request) Successful in 24s
simodels Build / Rustfmt (pull_request) Successful in 24s
simodels Build / Test Suite (pull_request) Successful in 26s
2026-11-04 16:10:29 -05:00
5 changed files with 43 additions and 14 deletions

No files matched your search

+16
View File
@@ -15,5 +15,21 @@ uuid = { version = "1.29.0", features = ["v4", "serde"] }
josekit = { version = "0.10.3" } josekit = { version = "0.10.3" }
utoipa = { version = "6.0.0", features = ["uuid", "time"] } 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] [dev-dependencies]
tempfile = { version = "3.27.0" } tempfile = { version = "3.27.0" }
+9 -7
View File
@@ -2,6 +2,8 @@ use std::default::Default;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
const DEFAULT_ACCESS_LEVEL: &str = super::constants::access_level::PUBLIC;
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)] #[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
pub struct AccessLevel { pub struct AccessLevel {
pub id: uuid::Uuid, pub id: uuid::Uuid,
@@ -13,8 +15,8 @@ impl Default for AccessLevel {
fn default() -> Self { fn default() -> Self {
AccessLevel { AccessLevel {
id: uuid::Uuid::nil(), id: uuid::Uuid::nil(),
level: String::new(), level: DEFAULT_ACCESS_LEVEL.to_string(),
song_id: uuid::Uuid::new_v4(), song_id: uuid::Uuid::nil(),
} }
} }
} }
@@ -22,16 +24,16 @@ impl Default for AccessLevel {
pub fn default_level() -> AccessLevel { pub fn default_level() -> AccessLevel {
AccessLevel { AccessLevel {
id: uuid::Uuid::nil(), id: uuid::Uuid::nil(),
level: String::from("Public"), level: DEFAULT_ACCESS_LEVEL.to_string(),
song_id: uuid::Uuid::new_v4(), song_id: uuid::Uuid::nil(),
} }
} }
pub fn private_level() -> AccessLevel { pub fn private_level() -> AccessLevel {
AccessLevel { AccessLevel {
id: uuid::Uuid::new_v4(), id: uuid::Uuid::nil(),
level: String::from("Private"), level: super::constants::access_level::PRIVATE.to_string(),
song_id: uuid::Uuid::new_v4(), song_id: uuid::Uuid::nil(),
} }
} }
+12
View File
@@ -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 mod error {
pub const DIRECTORY_NOT_INITIALIZED: &str = "Directory has not been initialized"; pub const DIRECTORY_NOT_INITIALIZED: &str = "Directory has not been initialized";
pub const FILENAME_NOT_INITIALIZED: &str = "Filename has not bee initialized"; pub const FILENAME_NOT_INITIALIZED: &str = "Filename has not bee initialized";
+5 -6
View File
@@ -1,9 +1,12 @@
#[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)]
pub struct SongEvent { pub struct SongEvent {
pub id: uuid::Uuid, pub id: uuid::Uuid,
pub song_id: uuid::Uuid, pub song_id: uuid::Uuid,
pub user_id: uuid::Uuid, pub user_id: uuid::Uuid,
pub event_type: String, pub event_type: String,
#[serde(with = "time::serde::rfc3339::option")]
pub event_time: Option<time::OffsetDateTime>, pub event_time: Option<time::OffsetDateTime>,
#[serde(with = "time::serde::rfc3339::option")]
pub date_created: Option<time::OffsetDateTime>, pub date_created: Option<time::OffsetDateTime>,
} }
@@ -11,12 +14,8 @@ impl SongEvent {
pub fn is_event_type_valid(&self) -> bool { pub fn is_event_type_valid(&self) -> bool {
matches!( matches!(
self.event_type.as_str(), 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";
+1 -1
View File
@@ -111,7 +111,7 @@ pub struct TokenResource {
pub id: uuid::Uuid, pub id: uuid::Uuid,
} }
pub const TOKEN_TYPE: &str = "JWT"; const TOKEN_TYPE: &str = "JWT";
pub fn create_token( pub fn create_token(
key: &String, key: &String,