Trait rsvg::error::AttributeResultExt
source · pub trait AttributeResultExt<O> {
// Required method
fn attribute(self, attr: QualName) -> Result<O, ElementError>;
}
Expand description
Helper for converting Result<O, E>
into Result<O, ElementError>
A ElementError
requires a QualName
that corresponds to the attribute to which the
error refers, plus the actual ValueErrorKind
that describes the error. However,
parsing functions for attribute value types will want to return their own kind of
error, instead of ValueErrorKind
. If that particular error type has an impl From<FooError> for ValueErrorKind
, then this trait helps assign attribute values in
set_atts()
methods as follows:
fn parse_foo(value: &str) -> Result<(), FooError>
// It is assumed that there is an impl From<FooError> for ValueErrorKind
let result = parse_foo("value").attribute(attr);
assert!(result.is_err());
The call to .attribute(attr)
converts the Result
from parse_foo()
into a full
ElementError
with the provided attr
.
Required Methods§
fn attribute(self, attr: QualName) -> Result<O, ElementError>
Implementations on Foreign Types§
source§impl<'i, O> AttributeResultExt<O> for Result<O, ParseError<'i>>
impl<'i, O> AttributeResultExt<O> for Result<O, ParseError<'i>>
Turns a short-lived ParseError
into a long-lived ElementError