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 anu32; - booleans converted from a text content between tags according to the XML
specification:
"true"and"1"converted totrue;"false"and"0"converted tofalse;
- 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;
Optionare always deserialized asSomeusing 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 toSimpleTypeDeserializer; - structs and maps are deserialized using new instance of
ElementMapAccess; - enums:
- the variant name is deserialized using
QNameDeserializerfrom 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_tupleof this deserializer; - struct variants: call
deserialize_structof this deserializer.
- unit variants: consuming a subtree and return
- the variant name is deserialized using
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,
impl<'de, 'd, R, E> ElementDeserializer<'de, 'd, R, E>where
R: XmlRead<'de>,
E: EntityResolver,
Sourcefn read_string(&mut self) -> Result<Cow<'de, str>, DeError>
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,
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>,
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>,
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>,
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>,
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>,
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>,
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>,
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>,
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>,
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>,
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>,
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>,
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
type Error = DeError
Source§fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting an i8 value.Source§fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting an i16 value.Source§fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting an i32 value.Source§fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting an i64 value.Source§fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting a u8 value.Source§fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting a u16 value.Source§fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting a u32 value.Source§fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting a u64 value.Source§fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting a f32 value.Source§fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting a f64 value.Source§fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting a bool value.Source§fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, DeError>where
V: Visitor<'de>,
Deserialize type is expecting a string value and does
not benefit from taking ownership of buffered data owned by the
Deserializer. Read moreSource§fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a unit value.Source§fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting an optional value. Read moreSource§fn deserialize_struct<V>(
self,
_name: &'static str,
fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_struct<V>(
self,
_name: &'static str,
fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_enum<V>(
self,
_name: &'static str,
_variants: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserializer to figure out how to drive the visitor based
on what data type is in the input. Read moreSource§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Deserialize implementations should expect to
deserialize their human-readable form. Read moreSource§impl<'de, 'd, R, E> EnumAccess<'de> for ElementDeserializer<'de, 'd, R, E>where
R: XmlRead<'de>,
E: EntityResolver,
impl<'de, 'd, R, E> EnumAccess<'de> for ElementDeserializer<'de, 'd, R, E>where
R: XmlRead<'de>,
E: EntityResolver,
Source§type Error = DeError
type Error = DeError
Source§type Variant = ElementDeserializer<'de, 'd, R, E>
type Variant = ElementDeserializer<'de, 'd, R, E>
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>,
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 moreSource§impl<'de, 'd, R, E> VariantAccess<'de> for ElementDeserializer<'de, 'd, R, E>where
R: XmlRead<'de>,
E: EntityResolver,
impl<'de, 'd, R, E> VariantAccess<'de> for ElementDeserializer<'de, 'd, R, E>where
R: XmlRead<'de>,
E: EntityResolver,
Source§type Error = DeError
type Error = DeError
EnumAccess.