pub trait Visitor<B: AsyncBufRead + Unpin> {
type Output;
// Required method
fn build(self) -> Result<Self::Output, Error>;
// Provided methods
fn start_name() -> Option<&'static str> { ... }
fn visit_tag(&mut self, name: &str) -> Result<(), Error> { ... }
fn visit_attribute(&mut self, name: &str, value: &str) -> Result<(), Error> { ... }
fn visit_child<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
reader: &'life2 mut PeekingReader<B>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn visit_text(&mut self, text: &str) -> Result<(), Error> { ... }
}
Expand description
A trait for building up instances of types during deserialization
As XmlReader::read_event_into_async()
does not return a Send
future, this entire trait must be ?Send
.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn start_name() -> Option<&'static str>
fn start_name() -> Option<&'static str>
Should return the expected starting tag name, if any
Sourcefn visit_tag(&mut self, name: &str) -> Result<(), Error>
fn visit_tag(&mut self, name: &str) -> Result<(), Error>
Visit the starting tag with the given name
This is called exactly once during deserialization and will be called before any other visit_*
methods.
Sourcefn visit_attribute(&mut self, name: &str, value: &str) -> Result<(), Error>
fn visit_attribute(&mut self, name: &str, value: &str) -> Result<(), Error>
Visit an attribute with the given name and value
Sourcefn visit_child<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
reader: &'life2 mut PeekingReader<B>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn visit_child<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
reader: &'life2 mut PeekingReader<B>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Visit a child element with the given tag name
Implementations must make sure the child element is read in some way. Most likely this will be either a
reader.skip_element()
or reader.deserialize()
call.
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.