1use super::prelude::*;
2
3#[derive(
4 IntoCursor, ToSpan, SemanticEq, Parse, Peek, ToCursors, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
5)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
7#[cfg_attr(feature = "visitable", derive(csskit_derives::Visitable), visit(self))]
8#[derive(csskit_derives::NodeWithMetadata)]
9#[metadata(node_kinds = Dimension)]
10pub struct Decibel(#[atom(CssAtomSet::Db)] T![Dimension]);
11
12impl From<Decibel> for f32 {
13 fn from(percentage: Decibel) -> Self {
14 percentage.0.into()
15 }
16}
17
18impl ToNumberValue for Decibel {
19 fn to_number_value(&self) -> Option<f32> {
20 Some((*self).into())
21 }
22}
23
24#[cfg(test)]
25mod tests {
26 use super::*;
27 use crate::CssAtomSet;
28 use css_parse::assert_parse;
29
30 #[test]
31 fn size_test() {
32 assert_eq!(std::mem::size_of::<Decibel>(), 12);
33 }
34
35 #[test]
36 fn test_writes() {
37 assert_parse!(CssAtomSet::ATOMS, Decibel, "1db");
38 }
39}