Files
simodels/src/login_result.rs
T
phoenixandphoenix 2d6b550ae6 tsk-57: Adding derive Schema to models (#58)
Closes #57

Reviewed-on: phoenix/icarus_models#58
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-08-24 23:42:04 +00:00

32 lines
730 B
Rust

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