use crate::schema::users; use diesel::prelude::*; /// User ID holder #[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)] pub struct UserID(pub i32); #[derive(Queryable, Debug)] pub struct User { pub id: i32, pub name: String, pub email: String, pub password: Option, pub reset_password_token: Option, pub time_create: i64, pub time_gen_reset_token: i64, pub time_activate: i64, pub active: bool, pub admin: bool, } impl User { pub fn id(&self) -> UserID { UserID(self.id) } } #[derive(Insertable)] #[diesel(table_name = users)] pub struct NewUser<'a> { pub name: &'a str, pub email: &'a str, pub time_create: i64, }