attribute_derive::parsing

Trait AttributeNamed

Source
pub trait AttributeNamed: AttributeBase {
    const PREFERRED_OPEN_DELIMITER: &'static str = " = ";
    const PREFERRED_CLOSE_DELIMITER: &'static str = "";

    // Required method
    fn parse_named(
        name: &'static str,
        input: ParseStream<'_>,
    ) -> Result<Option<Named<SpannedValue<Self::Partial>>>>;
}
Expand description

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.

Provided Associated Constants§

Source

const PREFERRED_OPEN_DELIMITER: &'static str = " = "

What open delimiter to use when providing error messages.

For <name> = <value>, this is " = ", for <function>(<like>), it is "(".

As named attributes can allow both <name> = <value> and name(<value>), this might not be the only way this attribute can be used.

Source

const PREFERRED_CLOSE_DELIMITER: &'static str = ""

What close delimiter to use when providing error messages.

For <name> = <value>, this is "", for <function>(<like>), it is ")".

As named attributes can allow both <name> = <value> and <name>(<value>), this might not be the only way this attribute can be used.

Required Methods§

Source

fn parse_named( name: &'static str, input: ParseStream<'_>, ) -> Result<Option<Named<SpannedValue<Self::Partial>>>>

Parses an attribute containing Self called name.

While this function can be implemented freely, the provided implementations support <name> = <value>, <function>(<like>) and <flag>.

Note: This needs to stop parsing at the end of the value, before a possible following , and further arguments.

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.

Implementations on Foreign Types§

Source§

impl AttributeNamed for bool

Source§

fn parse_named( name: &'static str, input: ParseStream<'_>, ) -> Result<Option<Named<SpannedValue<Self::Partial>>>>

Source§

impl<T: AttributeNamed> AttributeNamed for Option<T>

Source§

fn parse_named( name: &'static str, input: ParseStream<'_>, ) -> Result<Option<Named<SpannedValue<Self::Partial>>>>

Implementors§

Source§

impl<T: AttributeValue> AttributeNamed for FlagOrValue<T>

Source§

impl<T: AttributeValue> AttributeNamed for T

Source§

const PREFERRED_CLOSE_DELIMITER: &'static str = Self::PREFERRED_CLOSE_DELIMITER

Source§

const PREFERRED_OPEN_DELIMITER: &'static str = Self::PREFERRED_OPEN_DELIMITER