pub trait DeserializeXml: Default {
// Required method
fn from_reader<R: Read>(reader: &mut Peekable<Events<R>>) -> Result<Self>;
// Provided method
fn from_str(s: &str) -> Result<Self> { ... }
}Required Methods§
Sourcefn from_reader<R: Read>(reader: &mut Peekable<Events<R>>) -> Result<Self>
fn from_reader<R: Read>(reader: &mut Peekable<Events<R>>) -> Result<Self>
The beating heart of this trait. Implementations are expected to maintain the
following invariant: when DeserializeXml::from_reader is called, the
implementation will consume the next element from the reader (which will be a
StartElement event), as well as all elements up to and
including the corresponding EndElement event. The
implementation should use the data from those events to construct and return an
element of the type for which this trait is being implemented.
Note: technically the invariant isn’t true for the initial call, which might need
to consume some introductory elements (e.g., <xml>) before parsing in
earnest—that should be of no concern though, since the provided derive macro
is the intended entry point, and it handles this already.
Provided Methods§
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.