ezidam/crates/users/src/lib.rs

46 lines
953 B
Rust

mod database;
mod error;
use chrono::{DateTime, Utc};
use id::UserID;
pub use crate::error::Error;
#[derive(Debug)]
pub struct User {
id: UserID,
created_at: DateTime<Utc>,
updated_at: DateTime<Utc>,
is_admin: bool,
username: String,
name: Option<String>,
email: Option<String>,
password: Option<String>,
password_recover: Option<String>,
paper_key: Option<String>,
is_archived: bool,
}
impl User {
pub fn id(&self) -> &UserID {
&self.id
}
pub fn is_archived(&self) -> bool {
self.is_archived
}
pub fn password_hashed(&self) -> Option<&str> {
self.password.as_deref()
}
pub fn username(&self) -> &str {
&self.username
}
pub fn name(&self) -> Option<&str> {
self.name.as_deref()
}
pub fn email(&self) -> Option<&str> {
self.email.as_deref()
}
pub fn is_admin(&self) -> bool {
self.is_admin
}
}