Struct serde_test::Serializer
[−]
[src]
pub struct Serializer<'a, I> where I: Iterator<Item=&'a Token<'a>> { /* fields omitted */ }
Methods
impl<'a, I> Serializer<'a, I> where I: Iterator<Item=&'a Token<'a>>
[src]
fn new(tokens: I) -> Serializer<'a, I>
fn next_token(&mut self) -> Option<&'a Token<'a>>
Trait Implementations
impl<'s, 'a, I> Serializer for &'s mut Serializer<'a, I> where I: Iterator<Item=&'a Token<'a>>
[src]
type Ok = ()
Trickery to enforce correct use of the Serialize
trait. Every Serializer
should set Ok = ()
. Read more
type Error = Error
The error type when some error occurs during serialization.
type SerializeSeq = Self
Type returned from serialize_seq
and serialize_seq_fixed_size
for serializing the content of the sequence. Read more
type SerializeTuple = Self
Type returned from serialize_tuple
for serializing the content of the tuple. Read more
type SerializeTupleStruct = Self
Type returned from serialize_tuple_struct
for serializing the content of the tuple struct. Read more
type SerializeTupleVariant = Self
Type returned from serialize_tuple_variant
for serializing the content of the tuple variant. Read more
type SerializeMap = Self
Type returned from serialize_map
for serializing the content of the map. Read more
type SerializeStruct = Self
Type returned from serialize_struct
for serializing the content of the struct. Read more
type SerializeStructVariant = Self
Type returned from serialize_struct_variant
for serializing the content of the struct variant. Read more
fn serialize_bool(self, v: bool) -> Result<(), Error>
Serializes a bool
value.
fn serialize_isize(self, v: isize) -> Result<(), Error>
Serializes an isize
value. If the format does not differentiate between isize
and i64
, a reasonable implementation would be to cast the value to i64
and forward to serialize_i64
. Read more
fn serialize_i8(self, v: i8) -> Result<(), Error>
Serializes an i8
value. If the format does not differentiate between i8
and i64
, a reasonable implementation would be to cast the value to i64
and forward to serialize_i64
. Read more
fn serialize_i16(self, v: i16) -> Result<(), Error>
Serializes an i16
value. If the format does not differentiate between i16
and i64
, a reasonable implementation would be to cast the value to i64
and forward to serialize_i64
. Read more
fn serialize_i32(self, v: i32) -> Result<(), Error>
Serializes an i32
value. If the format does not differentiate between i32
and i64
, a reasonable implementation would be to cast the value to i64
and forward to serialize_i64
. Read more
fn serialize_i64(self, v: i64) -> Result<(), Error>
Serializes an i64
value.
fn serialize_usize(self, v: usize) -> Result<(), Error>
Serializes a usize
value. If the format does not differentiate between usize
and u64
, a reasonable implementation would be to cast the value to u64
and forward to serialize_u64
. Read more
fn serialize_u8(self, v: u8) -> Result<(), Error>
Serializes a u8
value. If the format does not differentiate between u8
and u64
, a reasonable implementation would be to cast the value to u64
and forward to serialize_u64
. Read more
fn serialize_u16(self, v: u16) -> Result<(), Error>
Serializes a u16
value. If the format does not differentiate between u16
and u64
, a reasonable implementation would be to cast the value to u64
and forward to serialize_u64
. Read more
fn serialize_u32(self, v: u32) -> Result<(), Error>
Serializes a u32
value. If the format does not differentiate between u32
and u64
, a reasonable implementation would be to cast the value to u64
and forward to serialize_u64
. Read more
fn serialize_u64(self, v: u64) -> Result<(), Error>
Serializes a
u64` value.
fn serialize_f32(self, v: f32) -> Result<(), Error>
Serializes an f32
value. If the format does not differentiate between f32
and f64
, a reasonable implementation would be to cast the value to f64
and forward to serialize_f64
. Read more
fn serialize_f64(self, v: f64) -> Result<(), Error>
Serializes an f64
value.
fn serialize_char(self, v: char) -> Result<(), Error>
Serializes a character. If the format does not support characters, it is reasonable to serialize it as a single element str
or a u32
. Read more
fn serialize_str(self, v: &str) -> Result<(), Error>
Serializes a &str
.
fn serialize_bytes(self, value: &[u8]) -> Result<(), Self::Error>
Enables serializers to serialize byte slices more compactly or more efficiently than other types of slices. If no efficient implementation is available, a reasonable implementation would be to forward to serialize_seq
. If forwarded, the implementation looks usually just like this: rust let mut seq = self.serialize_seq(Some(value.len()))?; for b in value { seq.serialize_element(b)?; } seq.end()
Read more
fn serialize_unit(self) -> Result<(), Error>
Serializes a ()
value. It's reasonable to just not serialize anything.
fn serialize_unit_struct(self, name: &str) -> Result<(), Error>
Serializes a unit struct value. A reasonable implementation would be to forward to serialize_unit
. Read more
fn serialize_unit_variant(self,
name: &str,
_variant_index: usize,
variant: &str)
-> Result<(), Error>
name: &str,
_variant_index: usize,
variant: &str)
-> Result<(), Error>
Serializes a unit variant, otherwise known as a variant with no arguments. A reasonable implementation would be to forward to serialize_unit
. Read more
fn serialize_newtype_struct<T: ?Sized>(self,
name: &'static str,
value: &T)
-> Result<(), Error> where T: Serialize
name: &'static str,
value: &T)
-> Result<(), Error> where T: Serialize
Allows a tuple struct with a single element, also known as a newtype struct, to be more efficiently serialized than a tuple struct with multiple items. A reasonable implementation would be to forward to serialize_tuple_struct
or to just serialize the inner value without wrapping. Read more
fn serialize_newtype_variant<T: ?Sized>(self,
name: &str,
_variant_index: usize,
variant: &str,
value: &T)
-> Result<(), Error> where T: Serialize
name: &str,
_variant_index: usize,
variant: &str,
value: &T)
-> Result<(), Error> where T: Serialize
Allows a variant with a single item to be more efficiently serialized than a variant with multiple items. A reasonable implementation would be to forward to serialize_tuple_variant
. Read more
fn serialize_none(self) -> Result<(), Error>
Serializes a None
value.
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<(), Error> where T: Serialize
Serializes a Some(...)
value.
fn serialize_seq(self, len: Option<usize>) -> Result<Self, Error>
Begins to serialize a sequence. This call must be followed by zero or more calls to serialize_seq_elt
, then a call to serialize_seq_end
. Read more
fn serialize_seq_fixed_size(self, len: usize) -> Result<Self, Error>
Begins to serialize a sequence whose length will be known at deserialization time. This call must be followed by zero or more calls to serialize_seq_elt
, then a call to serialize_seq_end
. A reasonable implementation would be to forward to serialize_seq
. Read more
fn serialize_tuple(self, len: usize) -> Result<Self, Error>
Begins to serialize a tuple. This call must be followed by zero or more calls to serialize_tuple_elt
, then a call to serialize_tuple_end
. A reasonable implementation would be to forward to serialize_seq
. Read more
fn serialize_tuple_struct(self,
name: &'static str,
len: usize)
-> Result<Self, Error>
name: &'static str,
len: usize)
-> Result<Self, Error>
Begins to serialize a tuple struct. This call must be followed by zero or more calls to serialize_tuple_struct_elt
, then a call to serialize_tuple_struct_end
. A reasonable implementation would be to forward to serialize_tuple
. Read more
fn serialize_tuple_variant(self,
name: &str,
_variant_index: usize,
variant: &str,
len: usize)
-> Result<Self, Error>
name: &str,
_variant_index: usize,
variant: &str,
len: usize)
-> Result<Self, Error>
Begins to serialize a tuple variant. This call must be followed by zero or more calls to serialize_tuple_variant_elt
, then a call to serialize_tuple_variant_end
. A reasonable implementation would be to forward to serialize_tuple_struct
. Read more
fn serialize_map(self, len: Option<usize>) -> Result<Self, Error>
Begins to serialize a map. This call must be followed by zero or more calls to serialize_map_key
and serialize_map_value
, then a call to serialize_map_end
. Read more
fn serialize_struct(self, name: &str, len: usize) -> Result<Self, Error>
Begins to serialize a struct. This call must be followed by zero or more calls to serialize_struct_elt
, then a call to serialize_struct_end
. Read more
fn serialize_struct_variant(self,
name: &str,
_variant_index: usize,
variant: &str,
len: usize)
-> Result<Self, Error>
name: &str,
_variant_index: usize,
variant: &str,
len: usize)
-> Result<Self, Error>
Begins to serialize a struct variant. This call must be followed by zero or more calls to serialize_struct_variant_elt
, then a call to serialize_struct_variant_end
. Read more
impl<'s, 'a, I> SerializeSeq for &'s mut Serializer<'a, I> where I: Iterator<Item=&'a Token<'a>>
[src]
type Ok = ()
Trickery to enforce correct use of the Serialize
trait. Every SerializeSeq
should set Ok = ()
. Read more
type Error = Error
The error type when some error occurs during serialization.
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Error> where T: Serialize
Serializes a sequence element.
fn end(self) -> Result<(), Error>
Finishes serializing a sequence.
impl<'s, 'a, I> SerializeTuple for &'s mut Serializer<'a, I> where I: Iterator<Item=&'a Token<'a>>
[src]
type Ok = ()
Trickery to enforce correct use of the Serialize
trait. Every SerializeTuple
should set Ok = ()
. Read more
type Error = Error
The error type when some error occurs during serialization.
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Error> where T: Serialize
Serializes a tuple element.
fn end(self) -> Result<(), Error>
Finishes serializing a tuple.
impl<'s, 'a, I> SerializeTupleStruct for &'s mut Serializer<'a, I> where I: Iterator<Item=&'a Token<'a>>
[src]
type Ok = ()
Trickery to enforce correct use of the Serialize
trait. Every SerializeTupleStruct
should set Ok = ()
. Read more
type Error = Error
The error type when some error occurs during serialization.
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Error> where T: Serialize
Serializes a tuple struct element.
fn end(self) -> Result<(), Error>
Finishes serializing a tuple struct.
impl<'s, 'a, I> SerializeTupleVariant for &'s mut Serializer<'a, I> where I: Iterator<Item=&'a Token<'a>>
[src]
type Ok = ()
Trickery to enforce correct use of the Serialize
trait. Every SerializeTupleVariant
should set Ok = ()
. Read more
type Error = Error
The error type when some error occurs during serialization.
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Error> where T: Serialize
Serializes a tuple variant element.
fn end(self) -> Result<(), Error>
Finishes serializing a tuple variant.
impl<'s, 'a, I> SerializeMap for &'s mut Serializer<'a, I> where I: Iterator<Item=&'a Token<'a>>
[src]
type Ok = ()
Trickery to enforce correct use of the Serialize
trait. Every SerializeMap
should set Ok = ()
. Read more
type Error = Error
The error type when some error occurs during serialization.
fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error> where T: Serialize
Serialize a map key.
fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error> where T: Serialize
Serialize a map value.
fn end(self) -> Result<(), Self::Error>
Finishes serializing a map.
impl<'s, 'a, I> SerializeStruct for &'s mut Serializer<'a, I> where I: Iterator<Item=&'a Token<'a>>
[src]
type Ok = ()
Trickery to enforce correct use of the Serialize
trait. Every SerializeStruct
should set Ok = ()
. Read more
type Error = Error
The error type when some error occurs during serialization.
fn serialize_field<T: ?Sized>(&mut self,
key: &'static str,
value: &T)
-> Result<(), Self::Error> where T: Serialize
key: &'static str,
value: &T)
-> Result<(), Self::Error> where T: Serialize
Serializes a struct field.
fn end(self) -> Result<(), Self::Error>
Finishes serializing a struct.
impl<'s, 'a, I> SerializeStructVariant for &'s mut Serializer<'a, I> where I: Iterator<Item=&'a Token<'a>>
[src]
type Ok = ()
Trickery to enforce correct use of the Serialize
trait. Every SerializeStructVariant
should set Ok = ()
. Read more
type Error = Error
The error type when some error occurs during serialization.
fn serialize_field<T: ?Sized>(&mut self,
key: &'static str,
value: &T)
-> Result<(), Self::Error> where T: Serialize
key: &'static str,
value: &T)
-> Result<(), Self::Error> where T: Serialize
Serialize a struct variant element.
fn end(self) -> Result<(), Self::Error>
Finishes serializing a struct variant.