mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 02:01:03 +00:00
add missing Vec<u8> deserialization hint to Deserializer
This commit is contained in:
+1
-1
@@ -234,7 +234,7 @@ mod bytebuf {
|
||||
fn deserialize<D>(deserializer: D) -> Result<ByteBuf, D::Error>
|
||||
where D: de::Deserializer
|
||||
{
|
||||
deserializer.deserialize_bytes(ByteBufVisitor)
|
||||
deserializer.deserialize_byte_buf(ByteBufVisitor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -174,6 +174,9 @@ pub enum Type {
|
||||
|
||||
/// Represents a `&[u8]` type.
|
||||
Bytes,
|
||||
|
||||
/// Represents a `Vec<u8>` type.
|
||||
ByteBuf,
|
||||
}
|
||||
|
||||
impl fmt::Display for Type {
|
||||
@@ -212,6 +215,7 @@ impl fmt::Display for Type {
|
||||
Type::UnitVariant => "unit variant",
|
||||
Type::NewtypeVariant => "newtype variant",
|
||||
Type::Bytes => "bytes",
|
||||
Type::ByteBuf => "bytes buf",
|
||||
};
|
||||
display.fmt(formatter)
|
||||
}
|
||||
@@ -343,12 +347,19 @@ pub trait Deserializer {
|
||||
visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor;
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting a `Vec<u8>`. This allows
|
||||
/// This method hints that the `Deserialize` type is expecting a `&[u8]`. This allows
|
||||
/// deserializers that provide a custom byte vector serialization to properly deserialize the
|
||||
/// type.
|
||||
fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor;
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting a `Vec<u8>`. This allows
|
||||
/// deserializers that provide a custom byte vector serialization to properly deserialize the
|
||||
/// type and prevent needless intermediate allocations that would occur when going through
|
||||
/// `&[u8]`.
|
||||
fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor;
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting a map of values. This allows
|
||||
/// deserializers to parse sequences that aren't tagged as maps.
|
||||
fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
|
||||
+12
-12
@@ -181,7 +181,7 @@ impl<E> de::Deserializer for UnitDeserializer<E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit seq seq_fixed_size bytes map unit_struct newtype_struct
|
||||
tuple_struct struct struct_field tuple enum ignored_any
|
||||
tuple_struct struct struct_field tuple enum ignored_any byte_buf
|
||||
}
|
||||
|
||||
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
@@ -223,7 +223,7 @@ macro_rules! primitive_deserializer {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str
|
||||
string unit option seq seq_fixed_size bytes map unit_struct
|
||||
newtype_struct tuple_struct struct struct_field tuple enum
|
||||
ignored_any
|
||||
ignored_any byte_buf
|
||||
}
|
||||
|
||||
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
@@ -288,7 +288,7 @@ impl<'a, E> de::Deserializer for StrDeserializer<'a, E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit option seq seq_fixed_size bytes map unit_struct newtype_struct
|
||||
tuple_struct struct struct_field tuple ignored_any
|
||||
tuple_struct struct struct_field tuple ignored_any byte_buf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ impl<E> de::Deserializer for StringDeserializer<E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit option seq seq_fixed_size bytes map unit_struct newtype_struct
|
||||
tuple_struct struct struct_field tuple ignored_any
|
||||
tuple_struct struct struct_field tuple ignored_any byte_buf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ impl<'a, E> de::Deserializer for CowStrDeserializer<'a, E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit option seq seq_fixed_size bytes map unit_struct newtype_struct
|
||||
tuple_struct struct struct_field tuple ignored_any
|
||||
tuple_struct struct struct_field tuple ignored_any byte_buf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ impl<I, T, E> de::Deserializer for SeqDeserializer<I, E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit option seq seq_fixed_size bytes map unit_struct newtype_struct
|
||||
tuple_struct struct struct_field tuple enum ignored_any
|
||||
tuple_struct struct struct_field tuple enum ignored_any byte_buf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,7 +572,7 @@ impl<V_, E> de::Deserializer for SeqVisitorDeserializer<V_, E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit option seq seq_fixed_size bytes map unit_struct newtype_struct
|
||||
tuple_struct struct struct_field tuple enum ignored_any
|
||||
tuple_struct struct struct_field tuple enum ignored_any byte_buf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,7 +675,7 @@ impl<I, K, V, E> de::Deserializer for MapDeserializer<I, K, V, E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit option bytes map unit_struct newtype_struct tuple_struct struct
|
||||
struct_field tuple enum ignored_any
|
||||
struct_field tuple enum ignored_any byte_buf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -772,7 +772,7 @@ impl<A, B, E> de::Deserializer for PairDeserializer<A, B, E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit option bytes map unit_struct newtype_struct tuple_struct struct
|
||||
struct_field tuple enum ignored_any
|
||||
struct_field tuple enum ignored_any byte_buf
|
||||
}
|
||||
|
||||
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
@@ -901,7 +901,7 @@ impl<V_, E> de::Deserializer for MapVisitorDeserializer<V_, E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit option seq seq_fixed_size bytes map unit_struct newtype_struct
|
||||
tuple_struct struct struct_field tuple enum ignored_any
|
||||
tuple_struct struct struct_field tuple enum ignored_any byte_buf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -934,7 +934,7 @@ impl<'a, E> de::Deserializer for BytesDeserializer<'a, E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit option seq seq_fixed_size bytes map unit_struct newtype_struct
|
||||
tuple_struct struct struct_field tuple enum ignored_any
|
||||
tuple_struct struct struct_field tuple enum ignored_any byte_buf
|
||||
}
|
||||
}
|
||||
|
||||
@@ -970,7 +970,7 @@ impl<E> de::Deserializer for ByteBufDeserializer<E>
|
||||
forward_to_deserialize! {
|
||||
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string
|
||||
unit option seq seq_fixed_size bytes map unit_struct newtype_struct
|
||||
tuple_struct struct struct_field tuple enum ignored_any
|
||||
tuple_struct struct struct_field tuple enum ignored_any byte_buf
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,9 @@ macro_rules! forward_to_deserialize_helper {
|
||||
(bytes) => {
|
||||
forward_to_deserialize_method!{deserialize_bytes()}
|
||||
};
|
||||
(byte_buf) => {
|
||||
forward_to_deserialize_method!{deserialize_byte_buf()}
|
||||
};
|
||||
(map) => {
|
||||
forward_to_deserialize_method!{deserialize_map()}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user