Module attribute_derive::parsing
source · 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§
- Helper struct to hold a value and the ident of its property.
- Helper struct to hold a value and the corresponding range.
Traits§
- Utility crate holding
Self::Partial
used in most attribute traits, i.e.,FromAttr
,AttributeValue
,AttributePositional
, … - Trait implementing parsing for
<function>(<like>)
attributes. - Values that can be parsed named, e.g.
<name>(<value>)
,<name> = <value>
,<name>
(as flag). - Trait implemented for attributes that can be parsed optionally as a positional argument, and the requirement for
Option<T>
to implementAttributePositional
. - Values that can be parsed positionally, i.e., without a name, e.g.
"literal"
,a + b
,true
. - Any values that can be parsed in an attribute input.
- Marker trait that enables the blanket implementation of
AttributePositional
forAttributeValue
.
Functions§
- Parses the name, if it matches returns
Some(name)
and removes thename
from input, ifNone
it does not modify the input.