Trait rsvg::parsers::ParseValue

source ·
pub trait ParseValue<T: Parse> {
    // Required method
    fn parse(&self, value: &str) -> Result<T, ElementError>;
}

Required Methods§

source

fn parse(&self, value: &str) -> Result<T, ElementError>

Parses a value string into a type T.

Implementations on Foreign Types§

source§

impl<T: Parse> ParseValue<T> for QualName

source§

fn parse(&self, value: &str) -> Result<T, ElementError>

Parse a value from an XML attribute.

Say we have an attribute bar like in <foo bar="42"/>. If attr is a [QualName] for the attribute bar, then we’ll parse it like attr.parse("42").

The reason for doing things that way is so that, in case of a parse error, this function can annotate the error result with the attribute’s name.

Note that attribute values are parsed entirely, thus the call to expect_exhausted() below. We don’t want to allow garbage in the string after the initial value has been parsed.

Implementors§