freya_core/values/
focusable.rs

1use crate::parsing::{
2    Parse,
3    ParseError,
4};
5
6#[derive(Clone, Debug, PartialEq, Default, Eq)]
7pub enum Focusable {
8    #[default]
9    Unknown,
10    Disabled,
11    Enabled,
12}
13
14impl Focusable {
15    pub fn is_unknown(&self) -> bool {
16        matches!(self, Self::Unknown)
17    }
18
19    pub fn is_enabled(&self) -> bool {
20        matches!(self, Self::Enabled)
21    }
22}
23
24impl Parse for Focusable {
25    fn parse(value: &str) -> Result<Self, ParseError> {
26        Ok(match value {
27            "true" => Self::Enabled,
28            "false" => Self::Disabled,
29            _ => Self::Unknown,
30        })
31    }
32}