Struct serde_json::value::Serializer
[−]
[src]
pub struct Serializer { /* fields omitted */ }Create a serde::Serializer that serializes a Serializee into a Value.
Methods
impl Serializer[src]
fn new() -> Serializer
Construct a new Serializer.
fn unwrap(self) -> Value
Unwrap the Serializer and return the Value.
Trait Implementations
impl Serializer for Serializer[src]
type Error = ()
The error type that can be returned if some error occurs during serialization.
fn visit_bool(&mut self, value: bool) -> Result<(), ()>
visit_bool serializes a bool value.
fn visit_i64(&mut self, value: i64) -> Result<(), ()>
visit_i64 serializes a i64 value.
fn visit_u64(&mut self, value: u64) -> Result<(), ()>
visit_u64 serializes a u64 value.
fn visit_f64(&mut self, value: f64) -> Result<(), ()>
visit_f64 serializes a f64 value.
fn visit_char(&mut self, value: char) -> Result<(), ()>
visit_char serializes a character. By default it serializes it as a &str containing a single character. Read more
fn visit_str(&mut self, value: &str) -> Result<(), ()>
visit_str serializes a &str.
fn visit_none(&mut self) -> Result<(), ()>
Serializes a None value.
fn visit_some<V>(&mut self, value: V) -> Result<(), ()> where
V: Serialize,
V: Serialize,
Serializes a Some(...) value.
fn visit_unit(&mut self) -> Result<(), ()>
Serializes a () value.
fn visit_unit_variant(
&mut self,
_name: &str,
_variant_index: usize,
variant: &str
) -> Result<(), ()>
&mut self,
_name: &str,
_variant_index: usize,
variant: &str
) -> Result<(), ()>
Serializes a unit variant, otherwise known as a variant with no arguments. Read more
fn visit_newtype_variant<T>(
&mut self,
_name: &str,
_variant_index: usize,
variant: &str,
value: T
) -> Result<(), ()> where
T: Serialize,
&mut self,
_name: &str,
_variant_index: usize,
variant: &str,
value: T
) -> Result<(), ()> where
T: Serialize,
The visit_newtype_variant allows a variant with a single item to be more efficiently serialized than a variant with multiple items. By default it just serializes the value as a tuple variant sequence. Read more
fn visit_seq<V>(&mut self, visitor: V) -> Result<(), ()> where
V: SeqVisitor,
V: SeqVisitor,
Serializes a sequence. Read more
fn visit_tuple_variant<V>(
&mut self,
_name: &str,
_variant_index: usize,
variant: &str,
visitor: V
) -> Result<(), ()> where
V: SeqVisitor,
&mut self,
_name: &str,
_variant_index: usize,
variant: &str,
visitor: V
) -> Result<(), ()> where
V: SeqVisitor,
Serializes a tuple variant. Read more
fn visit_seq_elt<T>(&mut self, value: T) -> Result<(), ()> where
T: Serialize,
T: Serialize,
Serializes a sequence element.
fn visit_map<V>(&mut self, visitor: V) -> Result<(), ()> where
V: MapVisitor,
V: MapVisitor,
Serializes a map. Read more
fn visit_struct_variant<V>(
&mut self,
_name: &str,
_variant_index: usize,
variant: &str,
visitor: V
) -> Result<(), ()> where
V: MapVisitor,
&mut self,
_name: &str,
_variant_index: usize,
variant: &str,
visitor: V
) -> Result<(), ()> where
V: MapVisitor,
Serializes a struct variant. Read more
fn visit_map_elt<K, V>(&mut self, key: K, value: V) -> Result<(), ()> where
K: Serialize,
V: Serialize,
K: Serialize,
V: Serialize,
Serializes a map element (key-value pair).
fn format() -> &'static str
Specify a format string for the serializer. Read more
fn visit_isize(&mut self, v: isize) -> Result<(), Self::Error>
visit_isize serializes a isize value. By default it casts the value to a i64 and passes it to the visit_i64 method. Read more
fn visit_i8(&mut self, v: i8) -> Result<(), Self::Error>
visit_i8 serializes a i8 value. By default it casts the value to a i64 and passes it to the visit_i64 method. Read more
fn visit_i16(&mut self, v: i16) -> Result<(), Self::Error>
visit_i16 serializes a i16 value. By default it casts the value to a i64 and passes it to the visit_i64 method. Read more
fn visit_i32(&mut self, v: i32) -> Result<(), Self::Error>
visit_i32 serializes a i32 value. By default it casts the value to a i64 and passes it to the visit_i64 method. Read more
fn visit_usize(&mut self, v: usize) -> Result<(), Self::Error>
visit_usize serializes a usize value. By default it casts the value to a u64 and passes it to the visit_u64 method. Read more
fn visit_u8(&mut self, v: u8) -> Result<(), Self::Error>
visit_u8 serializes a u8 value. By default it casts the value to a u64 and passes it to the visit_u64 method. Read more
fn visit_u16(&mut self, v: u16) -> Result<(), Self::Error>
visit_u32 serializes a u32 value. By default it casts the value to a u64 and passes it to the visit_u64 method. Read more
fn visit_u32(&mut self, v: u32) -> Result<(), Self::Error>
visit_u32 serializes a u32 value. By default it casts the value to a u64 and passes it to the visit_u64 method. Read more
fn visit_f32(&mut self, v: f32) -> Result<(), Self::Error>
visit_f32 serializes a f32 value. By default it casts the value to a f64 and passes it to the visit_f64 method. Read more
fn visit_bytes(&mut self, value: &[u8]) -> Result<(), Self::Error>
visit_bytes is a hook that enables those serialization formats that support serializing byte slices separately from generic arrays. By default it serializes as a regular array. Read more
fn visit_unit_struct(&mut self, _name: &'static str) -> Result<(), Self::Error>
Serializes a unit struct value. Read more
fn visit_newtype_struct<T>(
&mut self,
name: &'static str,
value: T
) -> Result<(), Self::Error> where
T: Serialize,
&mut self,
name: &'static str,
value: T
) -> Result<(), Self::Error> where
T: Serialize,
The visit_newtype_struct allows a tuple struct with a single element, also known as a newtyped value, to be more efficiently serialized than a tuple struct with multiple items. By default it just serializes the value as a tuple struct sequence. Read more
fn visit_tuple<V>(&mut self, visitor: V) -> Result<(), Self::Error> where
V: SeqVisitor,
V: SeqVisitor,
Serializes a tuple. Read more
fn visit_tuple_elt<T>(&mut self, value: T) -> Result<(), Self::Error> where
T: Serialize,
T: Serialize,
Serializes a tuple element. Read more
fn visit_tuple_struct<V>(
&mut self,
_name: &'static str,
visitor: V
) -> Result<(), Self::Error> where
V: SeqVisitor,
&mut self,
_name: &'static str,
visitor: V
) -> Result<(), Self::Error> where
V: SeqVisitor,
Serializes a tuple struct. Read more
fn visit_tuple_struct_elt<T>(&mut self, value: T) -> Result<(), Self::Error> where
T: Serialize,
T: Serialize,
Serializes a tuple struct element. Read more
fn visit_tuple_variant_elt<T>(&mut self, value: T) -> Result<(), Self::Error> where
T: Serialize,
T: Serialize,
Serializes a tuple element. Read more
fn visit_struct<V>(
&mut self,
_name: &'static str,
visitor: V
) -> Result<(), Self::Error> where
V: MapVisitor,
&mut self,
_name: &'static str,
visitor: V
) -> Result<(), Self::Error> where
V: MapVisitor,
Serializes a struct. Read more
fn visit_struct_elt<V>(
&mut self,
key: &'static str,
value: V
) -> Result<(), Self::Error> where
V: Serialize,
&mut self,
key: &'static str,
value: V
) -> Result<(), Self::Error> where
V: Serialize,
Serializes an element of a struct. Read more
fn visit_struct_variant_elt<V>(
&mut self,
key: &'static str,
value: V
) -> Result<(), Self::Error> where
V: Serialize,
&mut self,
key: &'static str,
value: V
) -> Result<(), Self::Error> where
V: Serialize,
Serializes an element of a struct variant. Read more