pub trait FromXml {
type Builder: FromEventsBuilder<Output = Self>;
// Required method
fn from_events(
name: QName,
attrs: AttrMap,
) -> Result<Self::Builder, FromEventsError>;
}
Expand description
Trait allowing to construct a struct from a stream of
rxml::Event
items.
To use this, first call FromXml::from_events
with the qualified
name and the attributes of the corresponding
rxml::Event::StartElement
event. If the call succeeds, the
returned builder object must be fed with the events representing the
contents of the element, and then with the EndElement
event.
The StartElement
passed to from_events
must not be passed to feed
.
Important: Changing the Builder
associated type
is considered a non-breaking change for any given implementation of this
trait. Always refer to a type’s builder type using fully-qualified
notation, for example: <T as xso::FromXml>::Builder
.
Required Associated Types§
sourcetype Builder: FromEventsBuilder<Output = Self>
type Builder: FromEventsBuilder<Output = Self>
A builder type used to construct the element.
Important: Changing this type is considered a non-breaking change
for any given implementation of this trait. Always refer to a type’s
builder type using fully-qualified notation, for example:
<T as xso::FromXml>::Builder
.
Required Methods§
sourcefn from_events(
name: QName,
attrs: AttrMap,
) -> Result<Self::Builder, FromEventsError>
fn from_events( name: QName, attrs: AttrMap, ) -> Result<Self::Builder, FromEventsError>
Attempt to initiate the streamed construction of this struct from XML.
If the passed qualified name
and attrs
match the element’s type,
the Self::Builder
is returned and should be fed with XML events
by the caller.
Otherwise, an appropriate error is returned.