Struct serde_tagged::de::adj::struc::KnownVisitor
source · pub struct KnownVisitor<T, V> { /* private fields */ }
Expand description
A visitor that can be used to deserialize a struct-based adjacently tagged value of known type.
This visitor handles a struct-based adjacently tagged value, which is represented by a struct containing exactly two fields. The first field of this tuple is named according to tag-key and contains tag, the second field is named according to value-key and contains the value. Thus this visitor will return an error if the visited type is not a map or sequence with two entries.
name
is the name with which the struct that will be serialized.
This visitor is intended for use of known values, i.e. when no tag-specific deserialization mehtod is required. Thus it does not need to cache values which can improve the performance.
§Note
If you do not need to choose a specific deserialization-method based on the
tag, you should prefer this visitor to Visitor
.
Implementations§
source§impl<T, V> KnownVisitor<T, V>
impl<T, V> KnownVisitor<T, V>
sourcepub fn new(
tag_seed: T,
value_seed: V,
tag_key: &'static str,
value_key: &'static str,
) -> Self
pub fn new( tag_seed: T, value_seed: V, tag_key: &'static str, value_key: &'static str, ) -> Self
Creates a new visitor with the given
SeedFactory
, tag-key and value-key.
Trait Implementations§
source§impl<'de, T, V> Visitor<'de> for KnownVisitor<T, V>where
T: DeserializeSeed<'de>,
V: DeserializeSeed<'de>,
impl<'de, T, V> Visitor<'de> for KnownVisitor<T, V>where
T: DeserializeSeed<'de>,
V: DeserializeSeed<'de>,
§type Value = (<T as DeserializeSeed<'de>>::Value, <V as DeserializeSeed<'de>>::Value)
type Value = (<T as DeserializeSeed<'de>>::Value, <V as DeserializeSeed<'de>>::Value)
source§fn expecting(&self, fmt: &mut Formatter<'_>) -> Result
fn expecting(&self, fmt: &mut Formatter<'_>) -> Result
source§fn visit_map<A>(self, map: A) -> Result<Self::Value, A::Error>where
A: MapAccess<'de>,
fn visit_map<A>(self, map: A) -> Result<Self::Value, A::Error>where
A: MapAccess<'de>,
source§fn visit_seq<A>(self, seq: A) -> Result<Self::Value, A::Error>where
A: SeqAccess<'de>,
fn visit_seq<A>(self, seq: A) -> Result<Self::Value, A::Error>where
A: SeqAccess<'de>,
source§fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>where
E: Error,
fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>where
E: Error,
source§fn visit_i8<E>(self, v: i8) -> Result<Self::Value, E>where
E: Error,
fn visit_i8<E>(self, v: i8) -> Result<Self::Value, E>where
E: Error,
i8
. Read moresource§fn visit_i16<E>(self, v: i16) -> Result<Self::Value, E>where
E: Error,
fn visit_i16<E>(self, v: i16) -> Result<Self::Value, E>where
E: Error,
i16
. Read moresource§fn visit_i32<E>(self, v: i32) -> Result<Self::Value, E>where
E: Error,
fn visit_i32<E>(self, v: i32) -> Result<Self::Value, E>where
E: Error,
i32
. Read moresource§fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>where
E: Error,
fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>where
E: Error,
i64
. Read moresource§fn visit_i128<E>(self, v: i128) -> Result<Self::Value, E>where
E: Error,
fn visit_i128<E>(self, v: i128) -> Result<Self::Value, E>where
E: Error,
i128
. Read moresource§fn visit_u8<E>(self, v: u8) -> Result<Self::Value, E>where
E: Error,
fn visit_u8<E>(self, v: u8) -> Result<Self::Value, E>where
E: Error,
u8
. Read moresource§fn visit_u16<E>(self, v: u16) -> Result<Self::Value, E>where
E: Error,
fn visit_u16<E>(self, v: u16) -> Result<Self::Value, E>where
E: Error,
u16
. Read moresource§fn visit_u32<E>(self, v: u32) -> Result<Self::Value, E>where
E: Error,
fn visit_u32<E>(self, v: u32) -> Result<Self::Value, E>where
E: Error,
u32
. Read moresource§fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>where
E: Error,
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>where
E: Error,
u64
. Read moresource§fn visit_u128<E>(self, v: u128) -> Result<Self::Value, E>where
E: Error,
fn visit_u128<E>(self, v: u128) -> Result<Self::Value, E>where
E: Error,
u128
. Read moresource§fn visit_f32<E>(self, v: f32) -> Result<Self::Value, E>where
E: Error,
fn visit_f32<E>(self, v: f32) -> Result<Self::Value, E>where
E: Error,
f32
. Read moresource§fn visit_f64<E>(self, v: f64) -> Result<Self::Value, E>where
E: Error,
fn visit_f64<E>(self, v: f64) -> Result<Self::Value, E>where
E: Error,
f64
. Read moresource§fn visit_char<E>(self, v: char) -> Result<Self::Value, E>where
E: Error,
fn visit_char<E>(self, v: char) -> Result<Self::Value, E>where
E: Error,
char
. Read moresource§fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>where
E: Error,
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>where
E: Error,
source§fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>where
E: Error,
fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>where
E: Error,
Deserializer
. Read moresource§fn visit_string<E>(self, v: String) -> Result<Self::Value, E>where
E: Error,
fn visit_string<E>(self, v: String) -> Result<Self::Value, E>where
E: Error,
Visitor
. Read moresource§fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>where
E: Error,
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>where
E: Error,
source§fn visit_borrowed_bytes<E>(self, v: &'de [u8]) -> Result<Self::Value, E>where
E: Error,
fn visit_borrowed_bytes<E>(self, v: &'de [u8]) -> Result<Self::Value, E>where
E: Error,
Deserializer
. Read moresource§fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>where
E: Error,
fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>where
E: Error,
Visitor
. Read moresource§fn visit_none<E>(self) -> Result<Self::Value, E>where
E: Error,
fn visit_none<E>(self) -> Result<Self::Value, E>where
E: Error,
source§fn visit_some<D>(
self,
deserializer: D,
) -> Result<Self::Value, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn visit_some<D>(
self,
deserializer: D,
) -> Result<Self::Value, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§fn visit_unit<E>(self) -> Result<Self::Value, E>where
E: Error,
fn visit_unit<E>(self) -> Result<Self::Value, E>where
E: Error,
()
. Read more