pub struct TextDeserializer<'de>(pub Text<'de>);
Expand description
A deserializer for a single text node of a mixed sequence of tags and text.
This deserializer are very similar to a MapValueDeserializer
(when it
processes the DeEvent::Text
event). The only difference in the
deserialize_seq
method. This deserializer will perform deserialization
from a textual content, 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 using
FromStr
; - booleans converted from the text according to the XML specification:
"true"
and"1"
converted totrue
;"false"
and"0"
converted tofalse
;
- strings returned as is;
- 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
:- empty text is deserialized as
None
; - everything else is deserialized as
Some
using the same deserializer;
- empty text is deserialized as
- units (
()
) and unit structs always deserialized successfully; - newtype structs forwards deserialization to the inner type using the same deserializer;
- sequences, tuples and tuple structs are deserialized using
SimpleTypeDeserializer
(this is the difference): text content passed to the deserializer directly; - structs and maps calls
Visitor::visit_borrowed_str
orVisitor::visit_string
, it is responsibility of the type to return an error if it do not able to process this data; - enums:
- the variant name is deserialized as
$text
; - the content is deserialized using the same deserializer:
- unit variants: just return
()
; - newtype variants forwards deserialization to the inner type using the same deserializer;
- tuple and struct variants are deserialized using
SimpleTypeDeserializer
.
- unit variants: just return
- the variant name is deserialized as
Tuple Fields§
§0: Text<'de>
Implementations§
Source§impl<'de> TextDeserializer<'de>
impl<'de> TextDeserializer<'de>
Sourcefn read_string(self) -> Result<Cow<'de, str>, DeError>
fn read_string(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> Deserializer<'de> for TextDeserializer<'de>
impl<'de> Deserializer<'de> for TextDeserializer<'de>
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:
<>
...
inner sequence as xs:list
...
</>
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> EnumAccess<'de> for TextDeserializer<'de>
impl<'de> EnumAccess<'de> for TextDeserializer<'de>
Source§type Error = DeError
type Error = DeError
Source§type Variant = TextDeserializer<'de>
type Variant = TextDeserializer<'de>
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> VariantAccess<'de> for TextDeserializer<'de>
impl<'de> VariantAccess<'de> for TextDeserializer<'de>
Source§type Error = DeError
type Error = DeError
EnumAccess
.