Skip to main content

peacock_crest/style/prop_validation/
word_break.rs

1use super::{CssValue, TokenExpected};
2use crate::Unit;
3
4#[derive(Debug, Clone)]
5pub struct CssWordBreak(Unit);
6
7#[derive(Debug, Clone, strum_macros::EnumString, strum_macros::Display)]
8pub enum KeywordWordBreak {
9    #[strum(to_string = "normal", serialize = "normal")]
10    Normal,
11
12    #[strum(to_string = "break-all", serialize = "break-all")]
13    BreakAll,
14
15    #[strum(to_string = "keep-all", serialize = "keep-all")]
16    KeepAll,
17
18    #[strum(to_string = "break-word", serialize = "break-word")]
19    BreakWord,
20}
21
22impl From<Unit> for CssWordBreak {
23    fn from(value: Unit) -> Self {
24        Self(value)
25    }
26}
27
28impl Into<Unit> for CssWordBreak {
29    fn into(self) -> Unit {
30        self.0
31    }
32}
33
34impl CssValue for CssWordBreak {
35    type Keyword = KeywordWordBreak;
36
37    fn type_name() -> &'static str {
38        "CssWordBreak"
39    }
40
41    fn type_token() -> TokenExpected {
42        TokenExpected::Ident
43    }
44}