Trait erased_serde::Serializer
[−]
[src]
pub trait Serializer { fn erased_serialize_bool(&mut self, _: bool) -> Result<(), Error>; fn erased_serialize_isize(&mut self, _: isize) -> Result<(), Error>; fn erased_serialize_i8(&mut self, _: i8) -> Result<(), Error>; fn erased_serialize_i16(&mut self, _: i16) -> Result<(), Error>; fn erased_serialize_i32(&mut self, _: i32) -> Result<(), Error>; fn erased_serialize_i64(&mut self, _: i64) -> Result<(), Error>; fn erased_serialize_usize(&mut self, _: usize) -> Result<(), Error>; fn erased_serialize_u8(&mut self, _: u8) -> Result<(), Error>; fn erased_serialize_u16(&mut self, _: u16) -> Result<(), Error>; fn erased_serialize_u32(&mut self, _: u32) -> Result<(), Error>; fn erased_serialize_u64(&mut self, _: u64) -> Result<(), Error>; fn erased_serialize_f32(&mut self, _: f32) -> Result<(), Error>; fn erased_serialize_f64(&mut self, _: f64) -> Result<(), Error>; fn erased_serialize_char(&mut self, _: char) -> Result<(), Error>; fn erased_serialize_str(&mut self, _: &str) -> Result<(), Error>; fn erased_serialize_bytes(&mut self, _: &[u8]) -> Result<(), Error>; fn erased_serialize_unit(&mut self) -> Result<(), Error>; fn erased_serialize_unit_struct(
&mut self,
name: &'static str
) -> Result<(), Error>; fn erased_serialize_unit_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str
) -> Result<(), Error>; fn erased_serialize_newtype_struct(
&mut self,
name: &'static str,
v: &Serialize
) -> Result<(), Error>; fn erased_serialize_newtype_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: &Serialize
) -> Result<(), Error>; fn erased_serialize_none(&mut self) -> Result<(), Error>; fn erased_serialize_some(&mut self, v: &Serialize) -> Result<(), Error>; fn erased_serialize_seq(
&mut self,
len: Option<usize>
) -> Result<SeqState, Error>; fn erased_serialize_seq_elt(
&mut self,
state: &mut SeqState,
v: &Serialize
) -> Result<(), Error>; fn erased_serialize_seq_end(&mut self, state: SeqState) -> Result<(), Error>; fn erased_serialize_seq_fixed_size(
&mut self,
size: usize
) -> Result<SeqState, Error>; fn erased_serialize_tuple(
&mut self,
len: usize
) -> Result<TupleState, Error>; fn erased_serialize_tuple_elt(
&mut self,
state: &mut TupleState,
v: &Serialize
) -> Result<(), Error>; fn erased_serialize_tuple_end(
&mut self,
state: TupleState
) -> Result<(), Error>; fn erased_serialize_tuple_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<TupleStructState, Error>; fn erased_serialize_tuple_struct_elt(
&mut self,
state: &mut TupleStructState,
v: &Serialize
) -> Result<(), Error>; fn erased_serialize_tuple_struct_end(
&mut self,
state: TupleStructState
) -> Result<(), Error>; fn erased_serialize_tuple_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<TupleVariantState, Error>; fn erased_serialize_tuple_variant_elt(
&mut self,
state: &mut TupleVariantState,
v: &Serialize
) -> Result<(), Error>; fn erased_serialize_tuple_variant_end(
&mut self,
state: TupleVariantState
) -> Result<(), Error>; fn erased_serialize_map(
&mut self,
len: Option<usize>
) -> Result<MapState, Error>; fn erased_serialize_map_key(
&mut self,
state: &mut MapState,
k: &Serialize
) -> Result<(), Error>; fn erased_serialize_map_value(
&mut self,
state: &mut MapState,
v: &Serialize
) -> Result<(), Error>; fn erased_serialize_map_end(&mut self, state: MapState) -> Result<(), Error>; fn erased_serialize_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<StructState, Error>; fn erased_serialize_struct_elt(
&mut self,
state: &mut StructState,
k: &'static str,
v: &Serialize
) -> Result<(), Error>; fn erased_serialize_struct_end(
&mut self,
state: StructState
) -> Result<(), Error>; fn erased_serialize_struct_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<StructVariantState, Error>; fn erased_serialize_struct_variant_elt(
&mut self,
state: &mut StructVariantState,
k: &'static str,
v: &Serialize
) -> Result<(), Error>; fn erased_serialize_struct_variant_end(
&mut self,
state: StructVariantState
) -> Result<(), Error>; }
Required Methods
fn erased_serialize_bool(&mut self, _: bool) -> Result<(), Error>
fn erased_serialize_isize(&mut self, _: isize) -> Result<(), Error>
fn erased_serialize_i8(&mut self, _: i8) -> Result<(), Error>
fn erased_serialize_i16(&mut self, _: i16) -> Result<(), Error>
fn erased_serialize_i32(&mut self, _: i32) -> Result<(), Error>
fn erased_serialize_i64(&mut self, _: i64) -> Result<(), Error>
fn erased_serialize_usize(&mut self, _: usize) -> Result<(), Error>
fn erased_serialize_u8(&mut self, _: u8) -> Result<(), Error>
fn erased_serialize_u16(&mut self, _: u16) -> Result<(), Error>
fn erased_serialize_u32(&mut self, _: u32) -> Result<(), Error>
fn erased_serialize_u64(&mut self, _: u64) -> Result<(), Error>
fn erased_serialize_f32(&mut self, _: f32) -> Result<(), Error>
fn erased_serialize_f64(&mut self, _: f64) -> Result<(), Error>
fn erased_serialize_char(&mut self, _: char) -> Result<(), Error>
fn erased_serialize_str(&mut self, _: &str) -> Result<(), Error>
fn erased_serialize_bytes(&mut self, _: &[u8]) -> Result<(), Error>
fn erased_serialize_unit(&mut self) -> Result<(), Error>
fn erased_serialize_unit_struct(
&mut self,
name: &'static str
) -> Result<(), Error>
&mut self,
name: &'static str
) -> Result<(), Error>
fn erased_serialize_unit_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str
) -> Result<(), Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str
) -> Result<(), Error>
fn erased_serialize_newtype_struct(
&mut self,
name: &'static str,
v: &Serialize
) -> Result<(), Error>
&mut self,
name: &'static str,
v: &Serialize
) -> Result<(), Error>
fn erased_serialize_newtype_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: &Serialize
) -> Result<(), Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: &Serialize
) -> Result<(), Error>
fn erased_serialize_none(&mut self) -> Result<(), Error>
fn erased_serialize_some(&mut self, v: &Serialize) -> Result<(), Error>
fn erased_serialize_seq(
&mut self,
len: Option<usize>
) -> Result<SeqState, Error>
&mut self,
len: Option<usize>
) -> Result<SeqState, Error>
fn erased_serialize_seq_elt(
&mut self,
state: &mut SeqState,
v: &Serialize
) -> Result<(), Error>
&mut self,
state: &mut SeqState,
v: &Serialize
) -> Result<(), Error>
fn erased_serialize_seq_end(&mut self, state: SeqState) -> Result<(), Error>
fn erased_serialize_seq_fixed_size(
&mut self,
size: usize
) -> Result<SeqState, Error>
&mut self,
size: usize
) -> Result<SeqState, Error>
fn erased_serialize_tuple(&mut self, len: usize) -> Result<TupleState, Error>
fn erased_serialize_tuple_elt(
&mut self,
state: &mut TupleState,
v: &Serialize
) -> Result<(), Error>
&mut self,
state: &mut TupleState,
v: &Serialize
) -> Result<(), Error>
fn erased_serialize_tuple_end(&mut self, state: TupleState) -> Result<(), Error>
fn erased_serialize_tuple_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<TupleStructState, Error>
&mut self,
name: &'static str,
len: usize
) -> Result<TupleStructState, Error>
fn erased_serialize_tuple_struct_elt(
&mut self,
state: &mut TupleStructState,
v: &Serialize
) -> Result<(), Error>
&mut self,
state: &mut TupleStructState,
v: &Serialize
) -> Result<(), Error>
fn erased_serialize_tuple_struct_end(
&mut self,
state: TupleStructState
) -> Result<(), Error>
&mut self,
state: TupleStructState
) -> Result<(), Error>
fn erased_serialize_tuple_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<TupleVariantState, Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<TupleVariantState, Error>
fn erased_serialize_tuple_variant_elt(
&mut self,
state: &mut TupleVariantState,
v: &Serialize
) -> Result<(), Error>
&mut self,
state: &mut TupleVariantState,
v: &Serialize
) -> Result<(), Error>
fn erased_serialize_tuple_variant_end(
&mut self,
state: TupleVariantState
) -> Result<(), Error>
&mut self,
state: TupleVariantState
) -> Result<(), Error>
fn erased_serialize_map(
&mut self,
len: Option<usize>
) -> Result<MapState, Error>
&mut self,
len: Option<usize>
) -> Result<MapState, Error>
fn erased_serialize_map_key(
&mut self,
state: &mut MapState,
k: &Serialize
) -> Result<(), Error>
&mut self,
state: &mut MapState,
k: &Serialize
) -> Result<(), Error>
fn erased_serialize_map_value(
&mut self,
state: &mut MapState,
v: &Serialize
) -> Result<(), Error>
&mut self,
state: &mut MapState,
v: &Serialize
) -> Result<(), Error>
fn erased_serialize_map_end(&mut self, state: MapState) -> Result<(), Error>
fn erased_serialize_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<StructState, Error>
&mut self,
name: &'static str,
len: usize
) -> Result<StructState, Error>
fn erased_serialize_struct_elt(
&mut self,
state: &mut StructState,
k: &'static str,
v: &Serialize
) -> Result<(), Error>
&mut self,
state: &mut StructState,
k: &'static str,
v: &Serialize
) -> Result<(), Error>
fn erased_serialize_struct_end(
&mut self,
state: StructState
) -> Result<(), Error>
&mut self,
state: StructState
) -> Result<(), Error>
fn erased_serialize_struct_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<StructVariantState, Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<StructVariantState, Error>
fn erased_serialize_struct_variant_elt(
&mut self,
state: &mut StructVariantState,
k: &'static str,
v: &Serialize
) -> Result<(), Error>
&mut self,
state: &mut StructVariantState,
k: &'static str,
v: &Serialize
) -> Result<(), Error>
fn erased_serialize_struct_variant_end(
&mut self,
state: StructVariantState
) -> Result<(), Error>
&mut self,
state: StructVariantState
) -> Result<(), Error>
Trait Implementations
impl<'a> Serializer for &'a mut Serializer
[src]
type Error = Error
The error type that can be returned if some error occurs during serialization.
type SeqState = SeqState
A state object that is initialized by serialize_seq
, passed to serialize_seq_elt
, and consumed by serialize_seq_end
. Use ()
if no state is required. Read more
type TupleState = TupleState
A state object that is initialized by serialize_tuple
, passed to serialize_tuple_elt
, and consumed by serialize_tuple_end
. Use ()
if no state is required. Read more
type TupleStructState = TupleStructState
A state object that is initialized by serialize_tuple_struct
, passed to serialize_tuple_struct_elt
, and consumed by serialize_tuple_struct_end
. Use ()
if no state is required. Read more
type TupleVariantState = TupleVariantState
A state object that is initialized by serialize_tuple_variant
, passed to serialize_tuple_variant_elt
, and consumed by serialize_tuple_variant_end
. Use ()
if no state is required. Read more
type MapState = MapState
A state object that is initialized by serialize_map
, passed to serialize_map_elt
, and consumed by serialize_map_end
. Use ()
if no state is required. Read more
type StructState = StructState
A state object that is initialized by serialize_struct
, passed to serialize_struct_elt
, and consumed by serialize_struct_end
. Use ()
if no state is required. Read more
type StructVariantState = StructVariantState
A state object that is initialized by serialize_struct_variant
, passed to serialize_struct_variant_elt
, and consumed by serialize_struct_variant_end
. Use ()
if no state is required. Read more
fn serialize_bool(&mut self, v: bool) -> Result<(), Error>
Serializes a bool
value.
fn serialize_isize(&mut 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(&mut 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(&mut 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(&mut 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(&mut self, v: i64) -> Result<(), Error>
Serializes an i64
value.
fn serialize_usize(&mut 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(&mut 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(&mut 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(&mut 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(&mut self, v: u64) -> Result<(), Error>
Serializes a
u64` value.
fn serialize_f32(&mut 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(&mut self, v: f64) -> Result<(), Error>
Serializes an f64
value.
fn serialize_char(&mut 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(&mut self, v: &str) -> Result<(), Error>
Serializes a &str
.
fn serialize_bytes(&mut self, v: &[u8]) -> Result<(), 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 state = try!(self.serialize_seq(value)); for b in value { try!(self.serialize_seq_elt(&mut state, b)); } self.serialize_seq_end(state)
Read more
fn serialize_unit(&mut self) -> Result<(), Error>
Serializes a ()
value. It's reasonable to just not serialize anything.
fn serialize_unit_struct(&mut self, name: &'static str) -> Result<(), Error>
Serializes a unit struct value. A reasonable implementation would be to forward to serialize_unit
. Read more
fn serialize_unit_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str
) -> Result<(), Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static 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: Serialize>(
&mut self,
name: &'static str,
v: T
) -> Result<(), Error>
&mut self,
name: &'static str,
v: T
) -> Result<(), Error>
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: Serialize>(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: T
) -> Result<(), Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: T
) -> Result<(), Error>
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(&mut self) -> Result<(), Error>
Serializes a None
value.
fn serialize_some<T: Serialize>(&mut self, v: T) -> Result<(), Error>
Serializes a Some(...)
value.
fn serialize_seq(&mut self, len: Option<usize>) -> Result<Self::SeqState, 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_elt<T: Serialize>(
&mut self,
state: &mut Self::SeqState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::SeqState,
v: T
) -> Result<(), Error>
Serializes a sequence element. Must have previously called serialize_seq
. Read more
fn serialize_seq_end(&mut self, state: Self::SeqState) -> Result<(), Error>
Finishes serializing a sequence.
fn serialize_seq_fixed_size(
&mut self,
size: usize
) -> Result<Self::SeqState, Error>
&mut self,
size: usize
) -> Result<Self::SeqState, 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(&mut self, len: usize) -> Result<Self::TupleState, 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_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleState,
v: T
) -> Result<(), Error>
Serializes a tuple element. Must have previously called serialize_tuple
. Read more
fn serialize_tuple_end(&mut self, state: Self::TupleState) -> Result<(), Error>
Finishes serializing a tuple.
fn serialize_tuple_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<Self::TupleStructState, Error>
&mut self,
name: &'static str,
len: usize
) -> Result<Self::TupleStructState, 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_struct_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleStructState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleStructState,
v: T
) -> Result<(), Error>
Serializes a tuple struct element. Must have previously called serialize_tuple_struct
. Read more
fn serialize_tuple_struct_end(
&mut self,
state: Self::TupleStructState
) -> Result<(), Error>
&mut self,
state: Self::TupleStructState
) -> Result<(), Error>
Finishes serializing a tuple struct.
fn serialize_tuple_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::TupleVariantState, Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::TupleVariantState, 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_tuple_variant_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleVariantState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleVariantState,
v: T
) -> Result<(), Error>
Serializes a tuple variant element. Must have previously called serialize_tuple_variant
. Read more
fn serialize_tuple_variant_end(
&mut self,
state: Self::TupleVariantState
) -> Result<(), Error>
&mut self,
state: Self::TupleVariantState
) -> Result<(), Error>
Finishes serializing a tuple variant.
fn serialize_map(&mut self, len: Option<usize>) -> Result<Self::MapState, 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_map_key<T: Serialize>(
&mut self,
state: &mut Self::MapState,
k: T
) -> Result<(), Error>
&mut self,
state: &mut Self::MapState,
k: T
) -> Result<(), Error>
Serialize a map key. Must have previously called serialize_map
.
fn serialize_map_value<T: Serialize>(
&mut self,
state: &mut Self::MapState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::MapState,
v: T
) -> Result<(), Error>
Serialize a map value. Must have previously called serialize_map
.
fn serialize_map_end(&mut self, state: Self::MapState) -> Result<(), Error>
Finishes serializing a map.
fn serialize_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<Self::StructState, Error>
&mut self,
name: &'static str,
len: usize
) -> Result<Self::StructState, 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_elt<V: Serialize>(
&mut self,
state: &mut Self::StructState,
k: &'static str,
v: V
) -> Result<(), Error>
&mut self,
state: &mut Self::StructState,
k: &'static str,
v: V
) -> Result<(), Error>
Serializes a struct field. Must have previously called serialize_struct
. Read more
fn serialize_struct_end(
&mut self,
state: Self::StructState
) -> Result<(), Error>
&mut self,
state: Self::StructState
) -> Result<(), Error>
Finishes serializing a struct.
fn serialize_struct_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::StructVariantState, Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::StructVariantState, 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
fn serialize_struct_variant_elt<V: Serialize>(
&mut self,
state: &mut Self::StructVariantState,
k: &'static str,
v: V
) -> Result<(), Error>
&mut self,
state: &mut Self::StructVariantState,
k: &'static str,
v: V
) -> Result<(), Error>
Serialize a struct variant element. Must have previously called serialize_struct_variant
. Read more
fn serialize_struct_variant_end(
&mut self,
state: Self::StructVariantState
) -> Result<(), Error>
&mut self,
state: Self::StructVariantState
) -> Result<(), Error>
Finishes serializing a struct variant.
impl<'a> Serializer for &'a mut Serializer + Send
[src]
type Error = Error
The error type that can be returned if some error occurs during serialization.
type SeqState = SeqState
A state object that is initialized by serialize_seq
, passed to serialize_seq_elt
, and consumed by serialize_seq_end
. Use ()
if no state is required. Read more
type TupleState = TupleState
A state object that is initialized by serialize_tuple
, passed to serialize_tuple_elt
, and consumed by serialize_tuple_end
. Use ()
if no state is required. Read more
type TupleStructState = TupleStructState
A state object that is initialized by serialize_tuple_struct
, passed to serialize_tuple_struct_elt
, and consumed by serialize_tuple_struct_end
. Use ()
if no state is required. Read more
type TupleVariantState = TupleVariantState
A state object that is initialized by serialize_tuple_variant
, passed to serialize_tuple_variant_elt
, and consumed by serialize_tuple_variant_end
. Use ()
if no state is required. Read more
type MapState = MapState
A state object that is initialized by serialize_map
, passed to serialize_map_elt
, and consumed by serialize_map_end
. Use ()
if no state is required. Read more
type StructState = StructState
A state object that is initialized by serialize_struct
, passed to serialize_struct_elt
, and consumed by serialize_struct_end
. Use ()
if no state is required. Read more
type StructVariantState = StructVariantState
A state object that is initialized by serialize_struct_variant
, passed to serialize_struct_variant_elt
, and consumed by serialize_struct_variant_end
. Use ()
if no state is required. Read more
fn serialize_bool(&mut self, v: bool) -> Result<(), Error>
Serializes a bool
value.
fn serialize_isize(&mut 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(&mut 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(&mut 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(&mut 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(&mut self, v: i64) -> Result<(), Error>
Serializes an i64
value.
fn serialize_usize(&mut 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(&mut 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(&mut 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(&mut 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(&mut self, v: u64) -> Result<(), Error>
Serializes a
u64` value.
fn serialize_f32(&mut 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(&mut self, v: f64) -> Result<(), Error>
Serializes an f64
value.
fn serialize_char(&mut 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(&mut self, v: &str) -> Result<(), Error>
Serializes a &str
.
fn serialize_bytes(&mut self, v: &[u8]) -> Result<(), 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 state = try!(self.serialize_seq(value)); for b in value { try!(self.serialize_seq_elt(&mut state, b)); } self.serialize_seq_end(state)
Read more
fn serialize_unit(&mut self) -> Result<(), Error>
Serializes a ()
value. It's reasonable to just not serialize anything.
fn serialize_unit_struct(&mut self, name: &'static str) -> Result<(), Error>
Serializes a unit struct value. A reasonable implementation would be to forward to serialize_unit
. Read more
fn serialize_unit_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str
) -> Result<(), Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static 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: Serialize>(
&mut self,
name: &'static str,
v: T
) -> Result<(), Error>
&mut self,
name: &'static str,
v: T
) -> Result<(), Error>
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: Serialize>(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: T
) -> Result<(), Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: T
) -> Result<(), Error>
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(&mut self) -> Result<(), Error>
Serializes a None
value.
fn serialize_some<T: Serialize>(&mut self, v: T) -> Result<(), Error>
Serializes a Some(...)
value.
fn serialize_seq(&mut self, len: Option<usize>) -> Result<Self::SeqState, 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_elt<T: Serialize>(
&mut self,
state: &mut Self::SeqState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::SeqState,
v: T
) -> Result<(), Error>
Serializes a sequence element. Must have previously called serialize_seq
. Read more
fn serialize_seq_end(&mut self, state: Self::SeqState) -> Result<(), Error>
Finishes serializing a sequence.
fn serialize_seq_fixed_size(
&mut self,
size: usize
) -> Result<Self::SeqState, Error>
&mut self,
size: usize
) -> Result<Self::SeqState, 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(&mut self, len: usize) -> Result<Self::TupleState, 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_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleState,
v: T
) -> Result<(), Error>
Serializes a tuple element. Must have previously called serialize_tuple
. Read more
fn serialize_tuple_end(&mut self, state: Self::TupleState) -> Result<(), Error>
Finishes serializing a tuple.
fn serialize_tuple_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<Self::TupleStructState, Error>
&mut self,
name: &'static str,
len: usize
) -> Result<Self::TupleStructState, 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_struct_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleStructState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleStructState,
v: T
) -> Result<(), Error>
Serializes a tuple struct element. Must have previously called serialize_tuple_struct
. Read more
fn serialize_tuple_struct_end(
&mut self,
state: Self::TupleStructState
) -> Result<(), Error>
&mut self,
state: Self::TupleStructState
) -> Result<(), Error>
Finishes serializing a tuple struct.
fn serialize_tuple_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::TupleVariantState, Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::TupleVariantState, 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_tuple_variant_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleVariantState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleVariantState,
v: T
) -> Result<(), Error>
Serializes a tuple variant element. Must have previously called serialize_tuple_variant
. Read more
fn serialize_tuple_variant_end(
&mut self,
state: Self::TupleVariantState
) -> Result<(), Error>
&mut self,
state: Self::TupleVariantState
) -> Result<(), Error>
Finishes serializing a tuple variant.
fn serialize_map(&mut self, len: Option<usize>) -> Result<Self::MapState, 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_map_key<T: Serialize>(
&mut self,
state: &mut Self::MapState,
k: T
) -> Result<(), Error>
&mut self,
state: &mut Self::MapState,
k: T
) -> Result<(), Error>
Serialize a map key. Must have previously called serialize_map
.
fn serialize_map_value<T: Serialize>(
&mut self,
state: &mut Self::MapState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::MapState,
v: T
) -> Result<(), Error>
Serialize a map value. Must have previously called serialize_map
.
fn serialize_map_end(&mut self, state: Self::MapState) -> Result<(), Error>
Finishes serializing a map.
fn serialize_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<Self::StructState, Error>
&mut self,
name: &'static str,
len: usize
) -> Result<Self::StructState, 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_elt<V: Serialize>(
&mut self,
state: &mut Self::StructState,
k: &'static str,
v: V
) -> Result<(), Error>
&mut self,
state: &mut Self::StructState,
k: &'static str,
v: V
) -> Result<(), Error>
Serializes a struct field. Must have previously called serialize_struct
. Read more
fn serialize_struct_end(
&mut self,
state: Self::StructState
) -> Result<(), Error>
&mut self,
state: Self::StructState
) -> Result<(), Error>
Finishes serializing a struct.
fn serialize_struct_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::StructVariantState, Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::StructVariantState, 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
fn serialize_struct_variant_elt<V: Serialize>(
&mut self,
state: &mut Self::StructVariantState,
k: &'static str,
v: V
) -> Result<(), Error>
&mut self,
state: &mut Self::StructVariantState,
k: &'static str,
v: V
) -> Result<(), Error>
Serialize a struct variant element. Must have previously called serialize_struct_variant
. Read more
fn serialize_struct_variant_end(
&mut self,
state: Self::StructVariantState
) -> Result<(), Error>
&mut self,
state: Self::StructVariantState
) -> Result<(), Error>
Finishes serializing a struct variant.
impl<'a> Serializer for &'a mut Serializer + Sync
[src]
type Error = Error
The error type that can be returned if some error occurs during serialization.
type SeqState = SeqState
A state object that is initialized by serialize_seq
, passed to serialize_seq_elt
, and consumed by serialize_seq_end
. Use ()
if no state is required. Read more
type TupleState = TupleState
A state object that is initialized by serialize_tuple
, passed to serialize_tuple_elt
, and consumed by serialize_tuple_end
. Use ()
if no state is required. Read more
type TupleStructState = TupleStructState
A state object that is initialized by serialize_tuple_struct
, passed to serialize_tuple_struct_elt
, and consumed by serialize_tuple_struct_end
. Use ()
if no state is required. Read more
type TupleVariantState = TupleVariantState
A state object that is initialized by serialize_tuple_variant
, passed to serialize_tuple_variant_elt
, and consumed by serialize_tuple_variant_end
. Use ()
if no state is required. Read more
type MapState = MapState
A state object that is initialized by serialize_map
, passed to serialize_map_elt
, and consumed by serialize_map_end
. Use ()
if no state is required. Read more
type StructState = StructState
A state object that is initialized by serialize_struct
, passed to serialize_struct_elt
, and consumed by serialize_struct_end
. Use ()
if no state is required. Read more
type StructVariantState = StructVariantState
A state object that is initialized by serialize_struct_variant
, passed to serialize_struct_variant_elt
, and consumed by serialize_struct_variant_end
. Use ()
if no state is required. Read more
fn serialize_bool(&mut self, v: bool) -> Result<(), Error>
Serializes a bool
value.
fn serialize_isize(&mut 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(&mut 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(&mut 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(&mut 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(&mut self, v: i64) -> Result<(), Error>
Serializes an i64
value.
fn serialize_usize(&mut 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(&mut 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(&mut 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(&mut 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(&mut self, v: u64) -> Result<(), Error>
Serializes a
u64` value.
fn serialize_f32(&mut 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(&mut self, v: f64) -> Result<(), Error>
Serializes an f64
value.
fn serialize_char(&mut 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(&mut self, v: &str) -> Result<(), Error>
Serializes a &str
.
fn serialize_bytes(&mut self, v: &[u8]) -> Result<(), 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 state = try!(self.serialize_seq(value)); for b in value { try!(self.serialize_seq_elt(&mut state, b)); } self.serialize_seq_end(state)
Read more
fn serialize_unit(&mut self) -> Result<(), Error>
Serializes a ()
value. It's reasonable to just not serialize anything.
fn serialize_unit_struct(&mut self, name: &'static str) -> Result<(), Error>
Serializes a unit struct value. A reasonable implementation would be to forward to serialize_unit
. Read more
fn serialize_unit_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str
) -> Result<(), Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static 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: Serialize>(
&mut self,
name: &'static str,
v: T
) -> Result<(), Error>
&mut self,
name: &'static str,
v: T
) -> Result<(), Error>
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: Serialize>(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: T
) -> Result<(), Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: T
) -> Result<(), Error>
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(&mut self) -> Result<(), Error>
Serializes a None
value.
fn serialize_some<T: Serialize>(&mut self, v: T) -> Result<(), Error>
Serializes a Some(...)
value.
fn serialize_seq(&mut self, len: Option<usize>) -> Result<Self::SeqState, 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_elt<T: Serialize>(
&mut self,
state: &mut Self::SeqState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::SeqState,
v: T
) -> Result<(), Error>
Serializes a sequence element. Must have previously called serialize_seq
. Read more
fn serialize_seq_end(&mut self, state: Self::SeqState) -> Result<(), Error>
Finishes serializing a sequence.
fn serialize_seq_fixed_size(
&mut self,
size: usize
) -> Result<Self::SeqState, Error>
&mut self,
size: usize
) -> Result<Self::SeqState, 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(&mut self, len: usize) -> Result<Self::TupleState, 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_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleState,
v: T
) -> Result<(), Error>
Serializes a tuple element. Must have previously called serialize_tuple
. Read more
fn serialize_tuple_end(&mut self, state: Self::TupleState) -> Result<(), Error>
Finishes serializing a tuple.
fn serialize_tuple_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<Self::TupleStructState, Error>
&mut self,
name: &'static str,
len: usize
) -> Result<Self::TupleStructState, 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_struct_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleStructState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleStructState,
v: T
) -> Result<(), Error>
Serializes a tuple struct element. Must have previously called serialize_tuple_struct
. Read more
fn serialize_tuple_struct_end(
&mut self,
state: Self::TupleStructState
) -> Result<(), Error>
&mut self,
state: Self::TupleStructState
) -> Result<(), Error>
Finishes serializing a tuple struct.
fn serialize_tuple_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::TupleVariantState, Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::TupleVariantState, 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_tuple_variant_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleVariantState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleVariantState,
v: T
) -> Result<(), Error>
Serializes a tuple variant element. Must have previously called serialize_tuple_variant
. Read more
fn serialize_tuple_variant_end(
&mut self,
state: Self::TupleVariantState
) -> Result<(), Error>
&mut self,
state: Self::TupleVariantState
) -> Result<(), Error>
Finishes serializing a tuple variant.
fn serialize_map(&mut self, len: Option<usize>) -> Result<Self::MapState, 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_map_key<T: Serialize>(
&mut self,
state: &mut Self::MapState,
k: T
) -> Result<(), Error>
&mut self,
state: &mut Self::MapState,
k: T
) -> Result<(), Error>
Serialize a map key. Must have previously called serialize_map
.
fn serialize_map_value<T: Serialize>(
&mut self,
state: &mut Self::MapState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::MapState,
v: T
) -> Result<(), Error>
Serialize a map value. Must have previously called serialize_map
.
fn serialize_map_end(&mut self, state: Self::MapState) -> Result<(), Error>
Finishes serializing a map.
fn serialize_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<Self::StructState, Error>
&mut self,
name: &'static str,
len: usize
) -> Result<Self::StructState, 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_elt<V: Serialize>(
&mut self,
state: &mut Self::StructState,
k: &'static str,
v: V
) -> Result<(), Error>
&mut self,
state: &mut Self::StructState,
k: &'static str,
v: V
) -> Result<(), Error>
Serializes a struct field. Must have previously called serialize_struct
. Read more
fn serialize_struct_end(
&mut self,
state: Self::StructState
) -> Result<(), Error>
&mut self,
state: Self::StructState
) -> Result<(), Error>
Finishes serializing a struct.
fn serialize_struct_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::StructVariantState, Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::StructVariantState, 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
fn serialize_struct_variant_elt<V: Serialize>(
&mut self,
state: &mut Self::StructVariantState,
k: &'static str,
v: V
) -> Result<(), Error>
&mut self,
state: &mut Self::StructVariantState,
k: &'static str,
v: V
) -> Result<(), Error>
Serialize a struct variant element. Must have previously called serialize_struct_variant
. Read more
fn serialize_struct_variant_end(
&mut self,
state: Self::StructVariantState
) -> Result<(), Error>
&mut self,
state: Self::StructVariantState
) -> Result<(), Error>
Finishes serializing a struct variant.
impl<'a> Serializer for &'a mut Serializer + Send + Sync
[src]
type Error = Error
The error type that can be returned if some error occurs during serialization.
type SeqState = SeqState
A state object that is initialized by serialize_seq
, passed to serialize_seq_elt
, and consumed by serialize_seq_end
. Use ()
if no state is required. Read more
type TupleState = TupleState
A state object that is initialized by serialize_tuple
, passed to serialize_tuple_elt
, and consumed by serialize_tuple_end
. Use ()
if no state is required. Read more
type TupleStructState = TupleStructState
A state object that is initialized by serialize_tuple_struct
, passed to serialize_tuple_struct_elt
, and consumed by serialize_tuple_struct_end
. Use ()
if no state is required. Read more
type TupleVariantState = TupleVariantState
A state object that is initialized by serialize_tuple_variant
, passed to serialize_tuple_variant_elt
, and consumed by serialize_tuple_variant_end
. Use ()
if no state is required. Read more
type MapState = MapState
A state object that is initialized by serialize_map
, passed to serialize_map_elt
, and consumed by serialize_map_end
. Use ()
if no state is required. Read more
type StructState = StructState
A state object that is initialized by serialize_struct
, passed to serialize_struct_elt
, and consumed by serialize_struct_end
. Use ()
if no state is required. Read more
type StructVariantState = StructVariantState
A state object that is initialized by serialize_struct_variant
, passed to serialize_struct_variant_elt
, and consumed by serialize_struct_variant_end
. Use ()
if no state is required. Read more
fn serialize_bool(&mut self, v: bool) -> Result<(), Error>
Serializes a bool
value.
fn serialize_isize(&mut 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(&mut 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(&mut 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(&mut 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(&mut self, v: i64) -> Result<(), Error>
Serializes an i64
value.
fn serialize_usize(&mut 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(&mut 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(&mut 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(&mut 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(&mut self, v: u64) -> Result<(), Error>
Serializes a
u64` value.
fn serialize_f32(&mut 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(&mut self, v: f64) -> Result<(), Error>
Serializes an f64
value.
fn serialize_char(&mut 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(&mut self, v: &str) -> Result<(), Error>
Serializes a &str
.
fn serialize_bytes(&mut self, v: &[u8]) -> Result<(), 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 state = try!(self.serialize_seq(value)); for b in value { try!(self.serialize_seq_elt(&mut state, b)); } self.serialize_seq_end(state)
Read more
fn serialize_unit(&mut self) -> Result<(), Error>
Serializes a ()
value. It's reasonable to just not serialize anything.
fn serialize_unit_struct(&mut self, name: &'static str) -> Result<(), Error>
Serializes a unit struct value. A reasonable implementation would be to forward to serialize_unit
. Read more
fn serialize_unit_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str
) -> Result<(), Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static 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: Serialize>(
&mut self,
name: &'static str,
v: T
) -> Result<(), Error>
&mut self,
name: &'static str,
v: T
) -> Result<(), Error>
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: Serialize>(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: T
) -> Result<(), Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
v: T
) -> Result<(), Error>
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(&mut self) -> Result<(), Error>
Serializes a None
value.
fn serialize_some<T: Serialize>(&mut self, v: T) -> Result<(), Error>
Serializes a Some(...)
value.
fn serialize_seq(&mut self, len: Option<usize>) -> Result<Self::SeqState, 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_elt<T: Serialize>(
&mut self,
state: &mut Self::SeqState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::SeqState,
v: T
) -> Result<(), Error>
Serializes a sequence element. Must have previously called serialize_seq
. Read more
fn serialize_seq_end(&mut self, state: Self::SeqState) -> Result<(), Error>
Finishes serializing a sequence.
fn serialize_seq_fixed_size(
&mut self,
size: usize
) -> Result<Self::SeqState, Error>
&mut self,
size: usize
) -> Result<Self::SeqState, 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(&mut self, len: usize) -> Result<Self::TupleState, 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_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleState,
v: T
) -> Result<(), Error>
Serializes a tuple element. Must have previously called serialize_tuple
. Read more
fn serialize_tuple_end(&mut self, state: Self::TupleState) -> Result<(), Error>
Finishes serializing a tuple.
fn serialize_tuple_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<Self::TupleStructState, Error>
&mut self,
name: &'static str,
len: usize
) -> Result<Self::TupleStructState, 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_struct_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleStructState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleStructState,
v: T
) -> Result<(), Error>
Serializes a tuple struct element. Must have previously called serialize_tuple_struct
. Read more
fn serialize_tuple_struct_end(
&mut self,
state: Self::TupleStructState
) -> Result<(), Error>
&mut self,
state: Self::TupleStructState
) -> Result<(), Error>
Finishes serializing a tuple struct.
fn serialize_tuple_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::TupleVariantState, Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::TupleVariantState, 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_tuple_variant_elt<T: Serialize>(
&mut self,
state: &mut Self::TupleVariantState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::TupleVariantState,
v: T
) -> Result<(), Error>
Serializes a tuple variant element. Must have previously called serialize_tuple_variant
. Read more
fn serialize_tuple_variant_end(
&mut self,
state: Self::TupleVariantState
) -> Result<(), Error>
&mut self,
state: Self::TupleVariantState
) -> Result<(), Error>
Finishes serializing a tuple variant.
fn serialize_map(&mut self, len: Option<usize>) -> Result<Self::MapState, 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_map_key<T: Serialize>(
&mut self,
state: &mut Self::MapState,
k: T
) -> Result<(), Error>
&mut self,
state: &mut Self::MapState,
k: T
) -> Result<(), Error>
Serialize a map key. Must have previously called serialize_map
.
fn serialize_map_value<T: Serialize>(
&mut self,
state: &mut Self::MapState,
v: T
) -> Result<(), Error>
&mut self,
state: &mut Self::MapState,
v: T
) -> Result<(), Error>
Serialize a map value. Must have previously called serialize_map
.
fn serialize_map_end(&mut self, state: Self::MapState) -> Result<(), Error>
Finishes serializing a map.
fn serialize_struct(
&mut self,
name: &'static str,
len: usize
) -> Result<Self::StructState, Error>
&mut self,
name: &'static str,
len: usize
) -> Result<Self::StructState, 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_elt<V: Serialize>(
&mut self,
state: &mut Self::StructState,
k: &'static str,
v: V
) -> Result<(), Error>
&mut self,
state: &mut Self::StructState,
k: &'static str,
v: V
) -> Result<(), Error>
Serializes a struct field. Must have previously called serialize_struct
. Read more
fn serialize_struct_end(
&mut self,
state: Self::StructState
) -> Result<(), Error>
&mut self,
state: Self::StructState
) -> Result<(), Error>
Finishes serializing a struct.
fn serialize_struct_variant(
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::StructVariantState, Error>
&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
len: usize
) -> Result<Self::StructVariantState, 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
fn serialize_struct_variant_elt<V: Serialize>(
&mut self,
state: &mut Self::StructVariantState,
k: &'static str,
v: V
) -> Result<(), Error>
&mut self,
state: &mut Self::StructVariantState,
k: &'static str,
v: V
) -> Result<(), Error>
Serialize a struct variant element. Must have previously called serialize_struct_variant
. Read more
fn serialize_struct_variant_end(
&mut self,
state: Self::StructVariantState
) -> Result<(), Error>
&mut self,
state: Self::StructVariantState
) -> Result<(), Error>
Finishes serializing a struct variant.
Implementors
impl<T: ?Sized> Serializer for T where
T: Serializer,