pub struct SingletonMap<D> {
pub delegate: D,
}
Expand description
A wrapper struct that delegates serialization and deserialization to an underlying serializer or deserializer.
This struct is used internally by the singleton_map
module to wrap the serializer or deserializer
and provide the necessary functionality for serializing and deserializing enums using the singleton map representation.
The SingletonMap
struct contains a single field, delegate
, which holds the underlying serializer or deserializer.
§Type Parameters
D
- The type of the underlying serializer or deserializer.
§Fields
delegate
- The underlying serializer or deserializer to which serialization and deserialization are delegated.
Fields§
§delegate: D
The underlying serializer or deserializer to which serialization and deserialization are delegated.
Trait Implementations§
Source§impl<D: Clone> Clone for SingletonMap<D>
impl<D: Clone> Clone for SingletonMap<D>
Source§fn clone(&self) -> SingletonMap<D>
fn clone(&self) -> SingletonMap<D>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<D: Debug> Debug for SingletonMap<D>
impl<D: Debug> Debug for SingletonMap<D>
Source§impl<'de, D> Deserializer<'de> for SingletonMap<D>where
D: Deserializer<'de>,
impl<'de, D> Deserializer<'de> for SingletonMap<D>where
D: Deserializer<'de>,
Source§type Error = <D as Deserializer<'de>>::Error
type Error = <D as Deserializer<'de>>::Error
The error type that can be returned if some error occurs during
deserialization.
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>,
Require the
Deserializer
to figure out how to drive the visitor based
on what data type is in the input. Read moreSource§fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a bool
value.Source§fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>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, Self::Error>where
V: Visitor<'de>,
fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>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, Self::Error>where
V: Visitor<'de>,
fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>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, Self::Error>where
V: Visitor<'de>,
fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting an i64
value.Source§fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Source§fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>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, Self::Error>where
V: Visitor<'de>,
fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>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, Self::Error>where
V: Visitor<'de>,
fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>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, Self::Error>where
V: Visitor<'de>,
fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a u64
value.Source§fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Source§fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>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, Self::Error>where
V: Visitor<'de>,
fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a f64
value.Source§fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a char
value.Source§fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>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 moreSource§fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a string value and would
benefit from taking ownership of buffered data owned by the
Deserializer
. Read moreSource§fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a byte array and does not
benefit from taking ownership of buffered data owned by the
Deserializer
. Read moreSource§fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a byte array and would
benefit from taking ownership of buffered data owned by the
Deserializer
. Read moreSource§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>,
Hint that the
Deserialize
type is expecting an optional value. 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>,
Hint that the
Deserialize
type is expecting a unit value.Source§fn deserialize_unit_struct<V>(
self,
name: &'static str,
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_unit_struct<V>(
self,
name: &'static str,
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a unit struct with a
particular name.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>,
Hint that the
Deserialize
type is expecting a newtype struct with a
particular name.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>,
Hint that the
Deserialize
type is expecting a sequence of values.Source§fn deserialize_tuple<V>(
self,
len: usize,
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_tuple<V>(
self,
len: usize,
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a sequence of values and
knows how many values there are without looking at the serialized data.Source§fn deserialize_tuple_struct<V>(
self,
name: &'static str,
len: usize,
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_tuple_struct<V>(
self,
name: &'static str,
len: usize,
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a tuple struct with a
particular name and number of fields.Source§fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a map of key-value pairs.Source§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>,
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>,
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_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting the name of a struct
field or the discriminant of an enum variant.Source§fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type needs to deserialize a value whose type
doesn’t matter because it is ignored. Read moreSource§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Determine whether
Deserialize
implementations should expect to
deserialize their human-readable form. Read moreSource§impl<D> Serialize for SingletonMap<D>where
D: Serialize,
impl<D> Serialize for SingletonMap<D>where
D: Serialize,
Source§impl<D> Serializer for SingletonMap<D>where
D: Serializer,
impl<D> Serializer for SingletonMap<D>where
D: Serializer,
Source§type Ok = <D as Serializer>::Ok
type Ok = <D as Serializer>::Ok
The output type produced by this
Serializer
during successful
serialization. Most serializers that produce text or binary output
should set Ok = ()
and serialize into an io::Write
or buffer
contained within the Serializer
instance. Serializers that build
in-memory data structures may be simplified by using Ok
to propagate
the data structure around.Source§type Error = <D as Serializer>::Error
type Error = <D as Serializer>::Error
The error type when some error occurs during serialization.
Source§type SerializeSeq = <D as Serializer>::SerializeSeq
type SerializeSeq = <D as Serializer>::SerializeSeq
Type returned from
serialize_seq
for serializing the content of the
sequence.Source§type SerializeTuple = <D as Serializer>::SerializeTuple
type SerializeTuple = <D as Serializer>::SerializeTuple
Type returned from
serialize_tuple
for serializing the content of
the tuple.Source§type SerializeTupleStruct = <D as Serializer>::SerializeTupleStruct
type SerializeTupleStruct = <D as Serializer>::SerializeTupleStruct
Type returned from
serialize_tuple_struct
for serializing the
content of the tuple struct.Source§type SerializeTupleVariant = SerializeTupleVariantAsSingletonMap<<D as Serializer>::SerializeMap>
type SerializeTupleVariant = SerializeTupleVariantAsSingletonMap<<D as Serializer>::SerializeMap>
Type returned from
serialize_tuple_variant
for serializing the
content of the tuple variant.Source§type SerializeMap = <D as Serializer>::SerializeMap
type SerializeMap = <D as Serializer>::SerializeMap
Type returned from
serialize_map
for serializing the content of the
map.Source§type SerializeStruct = <D as Serializer>::SerializeStruct
type SerializeStruct = <D as Serializer>::SerializeStruct
Type returned from
serialize_struct
for serializing the content of
the struct.Source§type SerializeStructVariant = SerializeStructVariantAsSingletonMap<<D as Serializer>::SerializeMap>
type SerializeStructVariant = SerializeStructVariantAsSingletonMap<<D as Serializer>::SerializeMap>
Type returned from
serialize_struct_variant
for serializing the
content of the struct variant.Source§fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>
fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>
Serialize a
bool
value. Read moreSource§fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>
fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>
Serialize an
i8
value. Read moreSource§fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>
fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>
Serialize an
i16
value. Read moreSource§fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>
fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>
Serialize an
i32
value. Read moreSource§fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>
fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>
Serialize an
i64
value. Read moreSource§fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error>
fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error>
Serialize an
i128
value. Read moreSource§fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>
fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>
Serialize a
u16
value. Read moreSource§fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>
fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>
Serialize a
u32
value. Read moreSource§fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>
fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>
Serialize a
u64
value. Read moreSource§fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error>
fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error>
Serialize a
u128
value. Read moreSource§fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>
fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>
Serialize an
f32
value. Read moreSource§fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>
fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>
Serialize an
f64
value. Read moreSource§fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error>
fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error>
Serialize a character. Read more
Source§fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>
fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>
Serialize a chunk of raw byte data. Read more
Source§fn serialize_unit_variant(
self,
name: &'static str,
variant_index: u32,
variant: &'static str,
) -> Result<Self::Ok, Self::Error>
fn serialize_unit_variant( self, name: &'static str, variant_index: u32, variant: &'static str, ) -> Result<Self::Ok, Self::Error>
Source§fn serialize_newtype_struct<T>(
self,
name: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
fn serialize_newtype_struct<T>( self, name: &'static str, value: &T, ) -> Result<Self::Ok, Self::Error>
Serialize a newtype struct like
struct Millimeters(u8)
. Read moreSource§fn serialize_newtype_variant<T>(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
fn serialize_newtype_variant<T>( self, _name: &'static str, _variant_index: u32, variant: &'static str, value: &T, ) -> Result<Self::Ok, Self::Error>
Source§fn serialize_seq(
self,
len: Option<usize>,
) -> Result<Self::SerializeSeq, Self::Error>
fn serialize_seq( self, len: Option<usize>, ) -> Result<Self::SerializeSeq, Self::Error>
Begin to serialize a variably sized sequence. This call must be
followed by zero or more calls to
serialize_element
, then a call to
end
. Read moreSource§fn serialize_tuple(
self,
len: usize,
) -> Result<Self::SerializeTuple, Self::Error>
fn serialize_tuple( self, len: usize, ) -> Result<Self::SerializeTuple, Self::Error>
Begin to serialize a statically sized sequence whose length will be
known at deserialization time without looking at the serialized data.
This call must be followed by zero or more calls to
serialize_element
,
then a call to end
. Read moreSource§fn serialize_tuple_struct(
self,
name: &'static str,
len: usize,
) -> Result<Self::SerializeTupleStruct, Self::Error>
fn serialize_tuple_struct( self, name: &'static str, len: usize, ) -> Result<Self::SerializeTupleStruct, Self::Error>
Begin to serialize a tuple struct like
struct Rgb(u8, u8, u8)
. This
call must be followed by zero or more calls to serialize_field
, then a
call to end
. Read moreSource§fn serialize_tuple_variant(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
len: usize,
) -> Result<Self::SerializeTupleVariant, Self::Error>
fn serialize_tuple_variant( self, _name: &'static str, _variant_index: u32, variant: &'static str, len: usize, ) -> Result<Self::SerializeTupleVariant, Self::Error>
Begin to serialize a tuple variant like
E::T
in enum E { T(u8, u8) }
. This call must be followed by zero or more calls to
serialize_field
, then a call to end
. Read moreSource§fn serialize_map(
self,
len: Option<usize>,
) -> Result<Self::SerializeMap, Self::Error>
fn serialize_map( self, len: Option<usize>, ) -> Result<Self::SerializeMap, Self::Error>
Begin to serialize a map. This call must be followed by zero or more
calls to
serialize_key
and serialize_value
, then a call to end
. Read moreSource§fn serialize_struct(
self,
name: &'static str,
len: usize,
) -> Result<Self::SerializeStruct, Self::Error>
fn serialize_struct( self, name: &'static str, len: usize, ) -> Result<Self::SerializeStruct, Self::Error>
Begin to serialize a struct like
struct Rgb { r: u8, g: u8, b: u8 }
.
This call must be followed by zero or more calls to serialize_field
,
then a call to end
. Read moreSource§fn serialize_struct_variant(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
len: usize,
) -> Result<Self::SerializeStructVariant, Self::Error>
fn serialize_struct_variant( self, _name: &'static str, _variant_index: u32, variant: &'static str, len: usize, ) -> Result<Self::SerializeStructVariant, Self::Error>
Begin to serialize a struct variant like
E::S
in enum E { S { r: u8, g: u8, b: u8 } }
. This call must be followed by zero or more calls to
serialize_field
, then a call to end
. Read moreSource§fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
Serialize a string produced by an implementation of
Display
. Read moreSource§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Determine whether
Serialize
implementations should serialize in
human-readable form. Read moreimpl<D: Copy> Copy for SingletonMap<D>
Auto Trait Implementations§
impl<D> Freeze for SingletonMap<D>where
D: Freeze,
impl<D> RefUnwindSafe for SingletonMap<D>where
D: RefUnwindSafe,
impl<D> Send for SingletonMap<D>where
D: Send,
impl<D> Sync for SingletonMap<D>where
D: Sync,
impl<D> Unpin for SingletonMap<D>where
D: Unpin,
impl<D> UnwindSafe for SingletonMap<D>where
D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)