mas_templates/context/
features.rs1use std::sync::Arc;
8
9use minijinja::{
10    Value,
11    value::{Enumerator, Object},
12};
13
14#[allow(clippy::struct_excessive_bools)]
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub struct SiteFeatures {
18    pub password_registration: bool,
20
21    pub password_registration_email_required: bool,
23
24    pub password_login: bool,
26
27    pub account_recovery: bool,
29
30    pub login_with_email_allowed: bool,
32}
33
34impl Object for SiteFeatures {
35    fn get_value(self: &Arc<Self>, field: &Value) -> Option<Value> {
36        match field.as_str()? {
37            "password_registration" => Some(Value::from(self.password_registration)),
38            "password_registration_email_required" => {
39                Some(Value::from(self.password_registration_email_required))
40            }
41            "password_login" => Some(Value::from(self.password_login)),
42            "account_recovery" => Some(Value::from(self.account_recovery)),
43            "login_with_email_allowed" => Some(Value::from(self.login_with_email_allowed)),
44            _ => None,
45        }
46    }
47
48    fn enumerate(self: &Arc<Self>) -> Enumerator {
49        Enumerator::Str(&[
50            "password_registration",
51            "password_registration_email_required",
52            "password_login",
53            "account_recovery",
54            "login_with_email_allowed",
55        ])
56    }
57}