pub trait DeserializeReader: XmlReader {
// Provided methods
fn read_attrib<T>(
&self,
store: &mut Option<T>,
name: &'static [u8],
value: &[u8],
) -> Result<(), Error>
where T: DeserializeBytes { ... }
fn raise_unexpected_attrib(
&self,
attrib: Attribute<'_>,
) -> Result<(), Error> { ... }
fn resolve_local_name<'a>(
&self,
name: QName<'a>,
ns: &[u8],
) -> Option<&'a [u8]> { ... }
fn check_start_tag_name(
&self,
event: &Event<'_>,
ns: Option<&[u8]>,
name: &[u8],
) -> bool { ... }
fn get_dynamic_type_name<'a>(
&self,
event: &'a Event<'_>,
) -> Result<Option<Cow<'a, [u8]>>, Error> { ... }
fn init_deserializer_from_start_event<'a, T, F>(
&self,
event: Event<'a>,
f: F,
) -> Result<DeserializerOutput<'a, T>, Error>
where T: WithDeserializer,
F: FnOnce(&Self, &BytesStart<'a>) -> Result<<T as WithDeserializer>::Deserializer, Error> { ... }
}
Expand description
Reader trait with additional helper methods for deserializing.
Provided Methods§
Sourcefn read_attrib<T>(
&self,
store: &mut Option<T>,
name: &'static [u8],
value: &[u8],
) -> Result<(), Error>where
T: DeserializeBytes,
fn read_attrib<T>(
&self,
store: &mut Option<T>,
name: &'static [u8],
value: &[u8],
) -> Result<(), Error>where
T: DeserializeBytes,
Helper function to convert and store an attribute from the XML event.
§Errors
Returns an Error
with ErrorKind::DuplicateAttribute
if store
already contained a value.
Sourcefn raise_unexpected_attrib(&self, attrib: Attribute<'_>) -> Result<(), Error>
fn raise_unexpected_attrib(&self, attrib: Attribute<'_>) -> Result<(), Error>
Raise the UnexpectedAttribute
error
for the passed attrib
.
§Errors
Will always return the UnexpectedAttribute
error.
Sourcefn resolve_local_name<'a>(&self, name: QName<'a>, ns: &[u8]) -> Option<&'a [u8]>
fn resolve_local_name<'a>(&self, name: QName<'a>, ns: &[u8]) -> Option<&'a [u8]>
Try to resolve the local name of the passed qname and the expected namespace.
Checks if the passed QName
name
matches the expected namespace ns
and returns the local name of it. If name
does not have a namespace prefix
to resolve, the local name is just returned as is.
Sourcefn get_dynamic_type_name<'a>(
&self,
event: &'a Event<'_>,
) -> Result<Option<Cow<'a, [u8]>>, Error>
fn get_dynamic_type_name<'a>( &self, event: &'a Event<'_>, ) -> Result<Option<Cow<'a, [u8]>>, Error>
Try to extract the type name of a dynamic type from the passed event.
This method will try to extract the name of a dynamic type from
Event::Start
or Event::Empty
by either using the explicit set name
in the type
attribute or by using the name of the xml tag.
§Errors
Raise an error if the attributes of the tag could not be resolved.
Sourcefn init_deserializer_from_start_event<'a, T, F>(
&self,
event: Event<'a>,
f: F,
) -> Result<DeserializerOutput<'a, T>, Error>where
T: WithDeserializer,
F: FnOnce(&Self, &BytesStart<'a>) -> Result<<T as WithDeserializer>::Deserializer, Error>,
fn init_deserializer_from_start_event<'a, T, F>(
&self,
event: Event<'a>,
f: F,
) -> Result<DeserializerOutput<'a, T>, Error>where
T: WithDeserializer,
F: FnOnce(&Self, &BytesStart<'a>) -> Result<<T as WithDeserializer>::Deserializer, Error>,
Initializes a deserializer from the passed event
.
If the event is Start
or Empty
, the passed
function f
is called with the BytesStart
from the event to initialize the actual
deserializer.
§Errors
Forwards the errors from raised by f
.
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.