torin/values/
content.rs

1#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2#[derive(PartialEq, Eq, Clone, Debug, Default)]
3pub enum Content {
4    #[default]
5    Normal,
6    Fit,
7    Flex,
8    Wrap,
9}
10
11impl Content {
12    pub fn is_fit(&self) -> bool {
13        self == &Self::Fit
14    }
15
16    pub fn is_flex(&self) -> bool {
17        self == &Self::Flex
18    }
19
20    pub fn is_wrap(&self) -> bool {
21        self == &Self::Wrap
22    }
23
24    pub fn allows_alignments(&self) -> bool {
25        matches!(self, Self::Normal | Self::Flex | Self::Fit)
26    }
27}
28
29impl Content {
30    pub fn pretty(&self) -> String {
31        match self {
32            Self::Normal => "normal".to_owned(),
33            Self::Fit => "fit".to_owned(),
34            Self::Flex => "flex".to_owned(),
35            Self::Wrap => "wrap".to_owned(),
36        }
37    }
38}