Skip to main content

peacock_crest/style/prop_validation/
object_fit.rs

1use super::{CssValue, TokenExpected};
2use crate::Unit;
3
4#[derive(Debug, Clone)]
5pub struct CssObjectFit(Unit);
6
7#[derive(Debug, Clone, strum_macros::EnumString, strum_macros::Display)]
8pub enum KeywordObjectFit {
9    #[strum(to_string = "contain", serialize = "contain")]
10    Contain,
11
12    #[strum(to_string = "cover", serialize = "cover")]
13    Cover,
14
15    #[strum(to_string = "fill", serialize = "fill")]
16    Fill,
17
18    #[strum(to_string = "none", serialize = "none")]
19    None,
20
21    #[strum(to_string = "scale-down", serialize = "scale-down")]
22    ScaleDown,
23}
24
25impl From<Unit> for CssObjectFit {
26    fn from(value: Unit) -> Self {
27        Self(value)
28    }
29}
30
31impl Into<Unit> for CssObjectFit {
32    fn into(self) -> Unit {
33        self.0
34    }
35}
36
37impl CssValue for CssObjectFit {
38    type Keyword = KeywordObjectFit;
39
40    fn type_name() -> &'static str {
41        "CssObjectFit"
42    }
43
44    fn type_token() -> TokenExpected {
45        TokenExpected::Ident
46    }
47}