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