DeserializeReader

Trait DeserializeReader 

Source
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§

Source

fn read_attrib<T>( &self, store: &mut Option<T>, name: &'static [u8], value: &[u8], ) -> Result<(), Error>

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.

Source

fn raise_unexpected_attrib(&self, attrib: Attribute<'_>) -> Result<(), Error>

Raise the UnexpectedAttribute error for the passed attrib.

§Errors

Will always return the UnexpectedAttribute error.

Source

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.

Source

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.

Source

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.

Source

fn check_start_tag_name( &self, event: &Event<'_>, ns: Option<&[u8]>, name: &[u8], ) -> bool

Try to extract the resolved tag name of either a Start or a Empty event.

Source

fn init_start_tag_deserializer<'a, T>( &self, event: Event<'a>, ns: Option<&[u8]>, name: &[u8], allow_any: bool, ) -> DeserializerResult<'a, T>

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.

Source

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.

Source

fn init_deserializer_from_start_event<'a, T, F>( &self, event: Event<'a>, f: F, ) -> Result<DeserializerOutput<'a, T>, 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.

Implementors§

Source§

impl<X> DeserializeReader for X
where X: XmlReader,