css_parse/syntax/
unknown_rule_block.rs1use super::prelude::*;
2use crate::ComponentValues;
3
4#[node]
8#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize), serde(transparent))]
10pub struct UnknownRuleBlock<'a, D = ComponentValues<'a>, M = ()> {
11 pub values: ComponentValues<'a>,
12 #[cfg_attr(feature = "serde", serde(skip))]
13 _phantom: std::marker::PhantomData<(D, M)>,
14}
15
16impl<'a, D, M> Parse<'a> for UnknownRuleBlock<'a, D, M> {
17 fn parse<Iter>(p: &mut Parser<'a, Iter>) -> Result<Self>
18 where
19 Iter: Iterator<Item = Cursor> + Clone,
20 {
21 ComponentValues::parse(p).map(|values| Self { values, _phantom: std::marker::PhantomData })
22 }
23}
24
25impl<'a, D, M> Peek<'a> for UnknownRuleBlock<'a, D, M> {
26 const PEEK_KINDSET: KindSet = ComponentValues::PEEK_KINDSET;
27}
28
29impl<'a, D, M> ToCursors for UnknownRuleBlock<'a, D, M> {
30 fn to_cursors(&self, s: &mut impl CursorSink) {
31 self.values.to_cursors(s)
32 }
33}
34
35impl<'a, D, M> ToSpan for UnknownRuleBlock<'a, D, M> {
36 fn to_span(&self) -> Span {
37 self.values.to_span()
38 }
39}
40
41impl<'a, D, M> SemanticEq for UnknownRuleBlock<'a, D, M> {
42 fn semantic_eq(&self, other: &Self) -> bool {
43 self.values.semantic_eq(&other.values)
44 }
45}
46
47impl<'a, D, M: NodeMetadata> NodeWithMetadata<M> for UnknownRuleBlock<'a, D, M> {
48 fn metadata(&self) -> M {
49 self.values.metadata()
50 }
51}
52
53impl<'a, D, M> crate::RuleVariants<'a> for UnknownRuleBlock<'a, D, M>
54where
55 D: DeclarationValue<'a, M>,
56 M: NodeMetadata,
57{
58 type DeclarationValue = D;
59 type Metadata = M;
60
61 fn is_unknown(&self) -> bool {
62 true
65 }
66}