Function rsvg::element::set_attribute

source ·
pub fn set_attribute<T>(
    dest: &mut T,
    parse_result: Result<T, ElementError>,
    session: &Session
)
Expand description

Sets dest if parse_result is Ok(), otherwise just logs the error.

Implementations of the ElementTrait trait generally scan a list of attributes for the ones they can handle, and parse their string values. Per the SVG spec, an attribute with an invalid value should be ignored, and it should fall back to the default value.

In librsvg, those default values are set in each element’s implementation of the Default trait: at element creation time, each element gets initialized to its Default, and then each attribute gets parsed. This function will set that attribute’s value only if parsing was successful.

In case the parse_result is an error, this function will log an appropriate notice via the Session.