use std::sync::Arc;
use minijinja::{
value::{Enumerator, Object},
Value,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SiteFeatures {
pub password_registration: bool,
pub password_login: bool,
pub account_recovery: bool,
}
impl Object for SiteFeatures {
fn get_value(self: &Arc<Self>, field: &Value) -> Option<Value> {
match field.as_str()? {
"password_registration" => Some(Value::from(self.password_registration)),
"password_login" => Some(Value::from(self.password_login)),
"account_recovery" => Some(Value::from(self.account_recovery)),
_ => None,
}
}
fn enumerate(self: &Arc<Self>) -> Enumerator {
Enumerator::Str(&[
"password_registration",
"password_login",
"account_recovery",
])
}
}