use askama::Template; use serde::{Deserialize, Serialize}; use crate::User; pub trait MaybeOptionalUser { fn has_optional_user() -> bool { false } } #[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)] #[template(path = "signup.html")] pub struct CreateUser { pub username: String, pub displayname: Option, pub email: Option, pub password: String, pub pw_verify: String, user: Option, } impl MaybeOptionalUser for CreateUser { fn has_optional_user() -> bool { true } } #[derive(Debug, Clone, Template, Default, Deserialize, Serialize, PartialEq, Eq)] #[template(path = "signup_success.html")] pub struct CreateUserSuccess { pub user: User, } impl MaybeOptionalUser for CreateUserSuccess { fn has_optional_user() -> bool { false } } #[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)] #[template(path = "login_post.html")] pub struct LoginPost { pub username: String, pub password: String, } impl MaybeOptionalUser for LoginPost { fn has_optional_user() -> bool { false } } #[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)] #[template(path = "login_get.html")] pub struct LoginGet { pub username: String, pub password: String, } impl MaybeOptionalUser for LoginGet { fn has_optional_user() -> bool { false } } #[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)] #[template(path = "logout_get.html")] pub struct LogoutGet; impl MaybeOptionalUser for LogoutGet { fn has_optional_user() -> bool { false } } #[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)] #[template(path = "logout_post.html")] pub struct LogoutPost; impl MaybeOptionalUser for LogoutPost { fn has_optional_user() -> bool { false } } #[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)] #[template(path = "index.html")] pub struct MainPage { pub user: Option, } impl MaybeOptionalUser for MainPage { fn has_optional_user() -> bool { true } }