Lang change

This commit is contained in:
KD
2025-03-09 00:54:02 +00:00
parent f7720f151b
commit c4d636ee4d
10 changed files with 155 additions and 29 deletions

26
src/access_level.rs Normal file
View File

@@ -0,0 +1,26 @@
use std::default::Default;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AccessLevel {
pub id: i32,
pub level: String,
pub song_id: i32,
}
impl Default for AccessLevel {
fn default() -> Self {
AccessLevel {
id: -1,
level: String::new(),
song_id: -1,
}
}
}
impl AccessLevel {
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
return serde_json::to_string_pretty(&self);
}
}

18
src/lib.rs Normal file
View File

@@ -0,0 +1,18 @@
pub mod access_level;
pub mod login_result;
pub mod user;
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

31
src/login_result.rs Normal file
View File

@@ -0,0 +1,31 @@
use std::default::Default;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct LoginResult {
pub id: i32,
pub username: String,
pub token: String,
#[serde(alias = "token_type")]
pub token_type: String,
pub expiration: i32,
}
impl Default for LoginResult {
fn default() -> Self {
LoginResult {
id: -1,
username: String::new(),
token: String::new(),
token_type: String::new(),
expiration: -1,
}
}
}
impl LoginResult {
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
return serde_json::to_string_pretty(&self);
}
}

42
src/user.rs Normal file
View File

@@ -0,0 +1,42 @@
use std::default::Default;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct User {
pub id: i32,
pub username: String,
pub password: String,
pub email: String,
pub phone: String,
pub firstname: String,
pub lastname: String,
pub email_verified: bool,
pub date_created: String,
pub status: String,
pub last_login: String,
}
impl Default for User {
fn default() -> Self {
User {
id: -1,
username: String::new(),
password: String::new(),
email: String::new(),
phone: String::new(),
firstname: String::new(),
lastname: String::new(),
email_verified: false,
date_created: String::new(),
status: String::new(),
last_login: String::new(),
}
}
}
impl User {
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
return serde_json::to_string_pretty(&self);
}
}