Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
6854a5e14d | |||
5d89ccb7c1 | |||
e429534100 | |||
1881650e9c | |||
e9ae99520c | |||
cd0ab2dec6 | |||
5d20d8576f | |||
3979a59665 | |||
a2371b7bf1 | |||
6bed8590ca | |||
daeb208448 | |||
9ffc1aad05 | |||
a08a879f5a | |||
d4b415dca3 | |||
55b51db4a0 | |||
76e28fc626 | |||
7b5cb41f4a | |||
fc362e4e21 | |||
689dbaf29a | |||
36ac93414b | |||
5b92d8857c | |||
03f5647d53 | |||
448c81fd1e | |||
67aaba4fbf |
@@ -44,10 +44,10 @@ deploy:
|
||||
stage: deploy
|
||||
image: rust:1.85
|
||||
script:
|
||||
- echo "Printing environment"
|
||||
- env
|
||||
- cargo login "$CARGO_LOGIN_TOKEN"
|
||||
- echo "Next step"
|
||||
- echo "Deployment will be configured when this is ready for use"
|
||||
# - env
|
||||
# Uncomment when you are ready for this to be published
|
||||
# - cargo login "$CARGO_LOGIN_TOKEN"
|
||||
# - cargo publish
|
||||
dependencies:
|
||||
- build
|
||||
|
@@ -2,7 +2,7 @@
|
||||
name = "icarus-models"
|
||||
description = "models used for the icarus project"
|
||||
license = "MIT"
|
||||
version = "0.1.1"
|
||||
version = "0.1.7"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
@@ -19,6 +19,22 @@ impl Default for AccessLevel {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_level() -> AccessLevel {
|
||||
return AccessLevel {
|
||||
id: -1,
|
||||
level: String::from("Public"),
|
||||
song_id: -1,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn private_level() -> AccessLevel {
|
||||
return AccessLevel {
|
||||
id: -1,
|
||||
level: String::from("Private"),
|
||||
song_id: -1,
|
||||
};
|
||||
}
|
||||
|
||||
impl AccessLevel {
|
||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
|
5
src/constants.rs
Normal file
5
src/constants.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
pub const DEFAULT_MUSIC_EXTENSION: &str = FLAC_EXTENSION;
|
||||
pub const FLAC_EXTENSION: &str = ".flac";
|
||||
pub const WAV_EXTENSION: &str = ".wav";
|
||||
pub const MPTHREE_EXTENSION: &str = ".mp3";
|
||||
pub const JPG_EXTENSION: &str = ".jpg";
|
@@ -1,6 +1,9 @@
|
||||
pub mod access_level;
|
||||
pub mod constants;
|
||||
pub mod login_result;
|
||||
pub mod song;
|
||||
pub mod token;
|
||||
pub mod types;
|
||||
pub mod user;
|
||||
|
||||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
|
73
src/song.rs
Normal file
73
src/song.rs
Normal file
@@ -0,0 +1,73 @@
|
||||
use std::default::Default;
|
||||
use std::io::Read;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Song {
|
||||
#[serde(alias = "id")]
|
||||
pub id: Option<i32>,
|
||||
pub title: Option<String>,
|
||||
pub artist: Option<String>,
|
||||
pub album: Option<String>,
|
||||
pub album_artist: Option<String>,
|
||||
pub genre: Option<String>,
|
||||
pub year: Option<i32>,
|
||||
pub duration: Option<i32>,
|
||||
pub track: Option<i32>,
|
||||
pub disc: Option<i32>,
|
||||
pub disc_count: Option<i32>,
|
||||
pub track_count: Option<i32>,
|
||||
pub audio_type: Option<String>,
|
||||
pub date_created: Option<String>,
|
||||
pub filename: Option<String>,
|
||||
pub user_id: Option<i32>,
|
||||
#[serde(skip)]
|
||||
pub data: Option<Vec<u8>>,
|
||||
#[serde(skip)]
|
||||
pub directory: Option<String>,
|
||||
#[serde(skip)]
|
||||
pub album_id: Option<i32>,
|
||||
#[serde(skip)]
|
||||
pub artist_id: Option<i32>,
|
||||
#[serde(skip)]
|
||||
pub genre_id: Option<i32>,
|
||||
#[serde(skip)]
|
||||
pub coverart_id: Option<i32>,
|
||||
}
|
||||
|
||||
impl Default for Song {
|
||||
fn default() -> Self {
|
||||
Song {
|
||||
id: None,
|
||||
title: None,
|
||||
artist: None,
|
||||
album: None,
|
||||
album_artist: None,
|
||||
genre: None,
|
||||
year: None,
|
||||
duration: None,
|
||||
track: None,
|
||||
disc: None,
|
||||
disc_count: None,
|
||||
track_count: None,
|
||||
audio_type: None,
|
||||
date_created: None,
|
||||
filename: None,
|
||||
user_id: None,
|
||||
data: None,
|
||||
directory: None,
|
||||
album_id: None,
|
||||
artist_id: None,
|
||||
genre_id: None,
|
||||
coverart_id: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Song {
|
||||
// TODO: Implement
|
||||
pub fn to_metadata_json(&self) -> Result<String, serde_json::Error> {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
}
|
||||
}
|
24
src/token.rs
24
src/token.rs
@@ -11,6 +11,22 @@ pub struct Token {
|
||||
pub issued: i32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct AccessToken {
|
||||
#[serde(alias = "user_id")]
|
||||
pub user_id: i32,
|
||||
#[serde(alias = "username")]
|
||||
pub username: String,
|
||||
#[serde(alias = "token")]
|
||||
pub token: String,
|
||||
#[serde(alias = "token_type")]
|
||||
pub token_type: String,
|
||||
#[serde(alias = "expiration")]
|
||||
pub expiration: i32,
|
||||
#[serde(alias = "message")]
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
impl Default for Token {
|
||||
fn default() -> Self {
|
||||
Token {
|
||||
@@ -23,6 +39,14 @@ impl Default for Token {
|
||||
}
|
||||
}
|
||||
|
||||
impl AccessToken {
|
||||
pub fn bearer_token(&self) -> String {
|
||||
let mut token: String = String::from("Bearer ");
|
||||
token += &self.token.clone();
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
impl Token {
|
||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
|
9
src/types.rs
Normal file
9
src/types.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use std::default::Default;
|
||||
|
||||
mod types {
|
||||
pub enum Types {
|
||||
WAV_EXTENSION,
|
||||
FLAC_EXTENSION,
|
||||
MP_EXTENSION,
|
||||
}
|
||||
}
|
22
src/user.rs
22
src/user.rs
@@ -4,19 +4,33 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct User {
|
||||
#[serde(skip_serializing_if = "is_id_valid")]
|
||||
pub id: i32,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub username: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub password: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub email: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub phone: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub firstname: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub lastname: String,
|
||||
pub email_verified: bool,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub date_created: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub status: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub last_login: String,
|
||||
}
|
||||
|
||||
fn is_id_valid(num: &i32) -> bool {
|
||||
*num > 0
|
||||
}
|
||||
|
||||
impl Default for User {
|
||||
fn default() -> Self {
|
||||
User {
|
||||
@@ -36,7 +50,11 @@ impl Default for User {
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
pub fn to_json(&self, output_pretty: bool) -> Result<String, serde_json::Error> {
|
||||
if output_pretty {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
} else {
|
||||
return serde_json::to_string(&self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user