freya_core/values/
layer.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::parsing::Parse;

#[derive(Clone, Copy, Debug, PartialEq)]
pub enum LayerMode {
    Inherited,
    Relative(i16),
    Overlay,
}

impl Parse for LayerMode {
    fn parse(value: &str) -> Result<Self, crate::parsing::ParseError> {
        Ok(match value {
            "overlay" => Self::Overlay,
            str => {
                if let Ok(relative) = str.parse::<i16>() {
                    Self::Relative(relative)
                } else {
                    Self::Inherited
                }
            }
        })
    }
}