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 raise_unexpected_attrib_checked(
&self,
attrib: Attribute<'_>,
) -> Result<(), Error> { ... }
fn is_globally_allowed_attrib(&self, attrib: &Attribute<'_>) -> bool { ... }
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 init_start_tag_deserializer<'a, T>(
&self,
event: Event<'a>,
ns: Option<&[u8]>,
name: &[u8],
allow_any: bool,
) -> DeserializerResult<'a, T>
where T: WithDeserializer { ... }
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 raise_unexpected_attrib_checked(
&self,
attrib: Attribute<'_>,
) -> Result<(), Error>
fn raise_unexpected_attrib_checked( &self, attrib: Attribute<'_>, ) -> Result<(), Error>
Raises an UnexpectedAttribute
error
for the given attribute if it is not globally allowed (e.g., an XSI attribute).
This method checks if the attribute is not globally allowed using
is_globally_allowed_attrib
and, if so, raises the error. Otherwise, it returns Ok(())
.
§Errors
Returns UnexpectedAttribute
if the
attribute is not globally allowed.
Sourcefn is_globally_allowed_attrib(&self, attrib: &Attribute<'_>) -> bool
fn is_globally_allowed_attrib(&self, attrib: &Attribute<'_>) -> bool
Returns true
if the given attribute is a globally allowed XML Schema
Instance (XSI) attribute, false
otherwise.
Specifically, this checks if the attribute is in the xsi
namespace and
has a local name of schemaLocation
, noNamespaceSchemaLocation
, type
,
or nil
. These attributes are globally valid and do not need to be
explicitly declared in the XML schema.
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 init_start_tag_deserializer<'a, T>(
&self,
event: Event<'a>,
ns: Option<&[u8]>,
name: &[u8],
allow_any: bool,
) -> DeserializerResult<'a, T>where
T: WithDeserializer,
fn init_start_tag_deserializer<'a, T>(
&self,
event: Event<'a>,
ns: Option<&[u8]>,
name: &[u8],
allow_any: bool,
) -> DeserializerResult<'a, T>where
T: WithDeserializer,
Try to initialize a deserializer for the given event
if it is a start
or empty tag that matches the passed ns
and name
.
If the event does not match the expectations, the returned DeserializerResult
will indicate continuation.
§Errors
Raises an error if the deserializer could not be initialized.
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.