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