Struct ElementDeserializer

Source
struct ElementDeserializer<'de, 'd, R, E>
where R: XmlRead<'de>, E: EntityResolver,
{ start: BytesStart<'de>, de: &'d mut Deserializer<'de, R, E>, }
Expand description

A deserializer for a single tag item of a mixed sequence of tags and text.

This deserializer are very similar to a MapValueDeserializer (when it processes the DeEvent::Start event). The only difference in the deserialize_seq method. This deserializer will perform deserialization from the textual content between start and end events, whereas the MapValueDeserializer will iterate over tags / text within it’s parent tag.

This deserializer processes items as following:

  • numbers are parsed from a text content between tags using FromStr. So, <int>123</int> can be deserialized into an u32;
  • booleans converted from a text content between tags according to the XML specification:
    • "true" and "1" converted to true;
    • "false" and "0" converted to false;
  • strings returned as a text content between tags;
  • characters also returned as strings. If string contain more than one character or empty, it is responsibility of a type to return an error;
  • Option are always deserialized as Some using the same deserializer, including <tag/> or <tag></tag>;
  • units (()) and unit structs consumes the whole element subtree;
  • newtype structs forwards deserialization to the inner type using SimpleTypeDeserializer;
  • sequences, tuples and tuple structs are deserialized using SimpleTypeDeserializer (this is the difference): text content between tags is passed to SimpleTypeDeserializer;
  • structs and maps are deserialized using new instance of ElementMapAccess;
  • enums:
    • the variant name is deserialized using QNameDeserializer from the element name;
    • the content is deserialized using the same deserializer:
      • unit variants: consuming a subtree and return ();
      • newtype variants forwards deserialization to the inner type using this deserializer;
      • tuple variants: call deserialize_tuple of this deserializer;
      • struct variants: call deserialize_struct of this deserializer.

Fields§

§start: BytesStart<'de>§de: &'d mut Deserializer<'de, R, E>

Implementations§

Source§

impl<'de, 'd, R, E> ElementDeserializer<'de, 'd, R, E>
where R: XmlRead<'de>, E: EntityResolver,

Source

fn read_string(&mut self) -> Result<Cow<'de, str>, DeError>

Returns a next string as concatenated content of consequent Text and CData events, used inside deserialize_primitives!().

Trait Implementations§

Source§

impl<'de, 'd, R, E> Deserializer<'de> for ElementDeserializer<'de, 'd, R, E>
where R: XmlRead<'de>, E: EntityResolver,

Source§

fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Character represented as strings.

Source§

fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Representation of owned strings the same as non-owned.

Source§

fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Forwards deserialization to the deserialize_any.

Source§

fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Forwards deserialization to the deserialize_bytes.

Source§

fn deserialize_unit_struct<V>( self, _name: &'static str, visitor: V, ) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Representation of the named units the same as unnamed units.

Source§

fn deserialize_tuple<V>( self, _len: usize, visitor: V, ) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Representation of tuples the same as sequences.

Source§

fn deserialize_tuple_struct<V>( self, _name: &'static str, len: usize, visitor: V, ) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Representation of named tuples the same as unnamed tuples.

Source§

fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Forwards deserialization to the deserialize_struct with empty name and fields.

Source§

fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Identifiers represented as strings.

Source§

fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Forwards deserialization to the deserialize_unit.

Source§

fn deserialize_newtype_struct<V>( self, _name: &'static str, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Forwards deserialization of the inner type. Always calls Visitor::visit_newtype_struct with this deserializer.

Source§

fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

This method deserializes a sequence inside of element that itself is a sequence element:

<>
  ...
  <self>inner sequence</self>
  <self>inner sequence</self>
  <self>inner sequence</self>
  ...
</>
Source§

type Error = DeError

The error type that can be returned if some error occurs during deserialization.
Source§

fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
Source§

fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
Source§

fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
Source§

fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
Source§

fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
Source§

fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
Source§

fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
Source§

fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
Source§

fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
Source§

fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
Source§

fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
Source§

fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
Source§

fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
Source§

fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
Source§

fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
Source§

fn deserialize_struct<V>( self, _name: &'static str, fields: &'static [&'static str], visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
Source§

fn deserialize_enum<V>( self, _name: &'static str, _variants: &'static [&'static str], visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
Source§

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
Source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
Source§

impl<'de, 'd, R, E> EnumAccess<'de> for ElementDeserializer<'de, 'd, R, E>
where R: XmlRead<'de>, E: EntityResolver,

Source§

type Error = DeError

The error type that can be returned if some error occurs during deserialization.
Source§

type Variant = ElementDeserializer<'de, 'd, R, E>

The Visitor that will be used to deserialize the content of the enum variant.
Source§

fn variant_seed<V>( self, seed: V, ) -> Result<(V::Value, Self::Variant), Self::Error>
where V: DeserializeSeed<'de>,

variant is called to identify which variant to deserialize. Read more
Source§

fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error>
where V: Deserialize<'de>,

variant is called to identify which variant to deserialize. Read more
Source§

impl<'de, 'd, R, E> VariantAccess<'de> for ElementDeserializer<'de, 'd, R, E>
where R: XmlRead<'de>, E: EntityResolver,

Source§

type Error = DeError

The error type that can be returned if some error occurs during deserialization. Must match the error type of our EnumAccess.
Source§

fn unit_variant(self) -> Result<(), Self::Error>

Called when deserializing a variant with no values. Read more
Source§

fn newtype_variant_seed<T>(self, seed: T) -> Result<T::Value, Self::Error>
where T: DeserializeSeed<'de>,

Called when deserializing a variant with a single value. Read more
Source§

fn tuple_variant<V>( self, len: usize, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Called when deserializing a tuple-like variant. Read more
Source§

fn struct_variant<V>( self, fields: &'static [&'static str], visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Called when deserializing a struct-like variant. Read more
Source§

fn newtype_variant<T>(self) -> Result<T, Self::Error>
where T: Deserialize<'de>,

Called when deserializing a variant with a single value. Read more

Auto Trait Implementations§

§

impl<'de, 'd, R, E> Freeze for ElementDeserializer<'de, 'd, R, E>

§

impl<'de, 'd, R, E> !RefUnwindSafe for ElementDeserializer<'de, 'd, R, E>

§

impl<'de, 'd, R, E> Send for ElementDeserializer<'de, 'd, R, E>
where R: Send, E: Send,

§

impl<'de, 'd, R, E> Sync for ElementDeserializer<'de, 'd, R, E>
where R: Sync, E: Sync,

§

impl<'de, 'd, R, E> Unpin for ElementDeserializer<'de, 'd, R, E>

§

impl<'de, 'd, R, E> !UnwindSafe for ElementDeserializer<'de, 'd, R, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.