Expand description
This module defines the traits defining how parsing works.
attribute-derive reuses the same traits for nested values and the root
attribute, this is why all traits in this module are named Attribute*.
FromAttr
Main entry point. Derived via macro. Anything that can be parsed from one or multiple attributes.
AttributeNamed
Values that can be parsed named, e.g. name(<value>), name = <value>, name (as flag).
This is the default parsing mode used for fields in derived FromAttr implementations.
AttributePositional
Values that can be parsed positionally, i.e., without a name, e.g. "literal", a + b, true.
When deriving FromAttr this is enabled via putting #[attr(positional)] on the field.
impl <T: AttributeValue> FromAttr for T
impl <T: AttributeValue> AttributeNamed for T
impl <T: AttributeValue + PositionalValue> AttributePositional for T
AttributeValue
Any attribute that has the concept of a value, e.g., "positional", meta(<value>), key = <value>.
impl <T: AttributeMeta> AttributeValue for T
AttributeMeta
Values in function or meta style attributes, i.e., meta(<value>).
Structs§
- Named
- Helper struct to hold a value and the ident of its property.
- Spanned
Value - Helper struct to hold a value and the corresponding range.
Traits§
- Attribute
Base - Utility crate holding
Self::Partialused in most attribute traits, i.e.,FromAttr,AttributeValue,AttributePositional, … - Attribute
Meta - Trait implementing parsing for
<function>(<like>)attributes. - Attribute
Named - Values that can be parsed named, e.g.
<name>(<value>),<name> = <value>,<name>(as flag). - Attribute
Peekable - Trait implemented for attributes that can be parsed optionally as a
positional argument, and the requirement for
Option<T>to implementAttributePositional. - Attribute
Positional - Values that can be parsed positionally, i.e., without a name, e.g.
"literal",a + b,true. - Attribute
Value - Any values that can be parsed in an attribute input.
- Positional
Value - Marker trait that enables the blanket implementation of
AttributePositionalforAttributeValue.
Functions§
- parse_
name - Parses the name, if it matches returns
Some(name)and removes thenamefrom input, ifNoneit does not modify the input.