mas_templates/context/
features.rs1use std::sync::Arc;
8
9use minijinja::{
10    Value,
11    value::{Enumerator, Object},
12};
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16pub struct SiteFeatures {
17    pub password_registration: bool,
19
20    pub password_login: bool,
22
23    pub account_recovery: bool,
25}
26
27impl Object for SiteFeatures {
28    fn get_value(self: &Arc<Self>, field: &Value) -> Option<Value> {
29        match field.as_str()? {
30            "password_registration" => Some(Value::from(self.password_registration)),
31            "password_login" => Some(Value::from(self.password_login)),
32            "account_recovery" => Some(Value::from(self.account_recovery)),
33            _ => None,
34        }
35    }
36
37    fn enumerate(self: &Arc<Self>) -> Enumerator {
38        Enumerator::Str(&[
39            "password_registration",
40            "password_login",
41            "account_recovery",
42        ])
43    }
44}