lewp_css/domain/
style_rule.rs1use {
5 super::{
6 properties::{Importance, PropertyDeclaration, PropertyDeclarations},
7 selectors::DeduplicatedSelectors,
8 HasPropertyDeclarations,
9 },
10 cssparser::ToCss,
11 std::fmt,
12};
13
14#[derive(Debug, Clone)]
16pub struct StyleRule {
17 pub selectors: DeduplicatedSelectors,
19
20 pub property_declarations: PropertyDeclarations<Importance>,
22}
23
24impl ToCss for StyleRule {
25 fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result {
27 self.selectors.to_css(dest)?;
28
29 dest.write_char('{')?;
30
31 self.property_declarations.to_css(dest)?;
32
33 dest.write_char('}')
34 }
35}
36
37impl HasPropertyDeclarations<Importance> for StyleRule {
38 #[inline(always)]
39 fn property_declarations(&self) -> &PropertyDeclarations<Importance> {
40 &self.property_declarations
41 }
42
43 #[inline(always)]
44 fn property_declarations_mut(
45 &mut self,
46 ) -> &mut PropertyDeclarations<Importance> {
47 &mut self.property_declarations
48 }
49
50 #[inline(always)]
51 fn property_declarations_slice(
52 &self,
53 ) -> &[PropertyDeclaration<Importance>] {
54 &self.property_declarations.0[..]
55 }
56
57 #[inline(always)]
58 fn property_declarations_vec(
59 &self,
60 ) -> &Vec<PropertyDeclaration<Importance>> {
61 &self.property_declarations.0
62 }
63
64 #[inline(always)]
65 fn property_declarations_vec_mut(
66 &mut self,
67 ) -> &mut Vec<PropertyDeclaration<Importance>> {
68 &mut self.property_declarations.0
69 }
70}