pub trait RuleVariants<'a>:
Sized
+ ToCursors
+ ToSpan {
// Provided methods
fn parse_at_rule(p: &mut Parser<'a>, _name: Cursor) -> Result<Self> { ... }
fn parse_unknown_at_rule(p: &mut Parser<'a>, _name: Cursor) -> Result<Self> { ... }
fn parse_qualified_rule(p: &mut Parser<'a>, _name: Cursor) -> Result<Self> { ... }
fn parse_unknown_qualified_rule(
p: &mut Parser<'a>,
_name: Cursor,
) -> Result<Self> { ... }
fn bad_declaration(_: BadDeclaration<'a>) -> Option<Self> { ... }
fn parse_rule_variants(p: &mut Parser<'a>) -> Result<Self> { ... }
}
Expand description
A trait that can be used for AST nodes representing a Declaration’s Value. It offers some convenience functions for handling such values.
Provided Methods§
Sourcefn parse_at_rule(p: &mut Parser<'a>, _name: Cursor) -> Result<Self>
fn parse_at_rule(p: &mut Parser<'a>, _name: Cursor) -> Result<Self>
Like crate::Parse::parse() but with the additional context of the name
Cursor. This cursor is known to be
an AtKeyword, therefore this should return a Self
reflecting a AtRule. If the
AtRule is not known, or otherwise fails then this should Err and RuleVariants::parse_unknown_at_rule() can
be called.
The default implementation of this method is to return an Unexpected Err.
Sourcefn parse_unknown_at_rule(p: &mut Parser<'a>, _name: Cursor) -> Result<Self>
fn parse_unknown_at_rule(p: &mut Parser<'a>, _name: Cursor) -> Result<Self>
Like crate::Parse::parse() but with the additional context of the name
Cursor. This cursor is known to be
an AtKeyword and that RuleVariants::parse_at_rule() failed. This should therefore return a Self that represents
an Unknwon AtRule, or otherwise Err.
The default implementation of this method is to return an Unexpected Err.
Sourcefn parse_qualified_rule(p: &mut Parser<'a>, _name: Cursor) -> Result<Self>
fn parse_qualified_rule(p: &mut Parser<'a>, _name: Cursor) -> Result<Self>
Like crate::Parse::parse() but with the additional context that the next cursor is not an AtKeyword, therefore this can attempt to parse a Qualified Rule. If the rule fails to parse, then RuleVariants::parse_unknown_qualified_rule() will be called.
The default implementation of this method is to return an Unexpected Err.
Sourcefn parse_unknown_qualified_rule(
p: &mut Parser<'a>,
_name: Cursor,
) -> Result<Self>
fn parse_unknown_qualified_rule( p: &mut Parser<'a>, _name: Cursor, ) -> Result<Self>
Like crate::Parse::parse() but with the additional context that the next cursor is not an AtKeyword, and that RuleVariants::parse_qualified_rule() has failed. Therefore this should attempt to parse an Unknown Qualified Rule, or Err.
The default implementation of this method is to return an Unexpected Err.
Sourcefn bad_declaration(_: BadDeclaration<'a>) -> Option<Self>
fn bad_declaration(_: BadDeclaration<'a>) -> Option<Self>
If all of the parse steps have failed, including parsing the Unknown Qualified Rule, we may want to consume a bad declaration (especially if the parser is in a nested context). This is done automatically on failing to parse an Unknown Qualified Rule, and this method is given the BadDeclaration.
This should attempt to build a Self that represents the BadDeclaration, or return None so RuleVariants::parse_rule_variants() can Err.
The default implementation of this method is to return None.
fn parse_rule_variants(p: &mut Parser<'a>) -> Result<Self>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.