Struct serde_json::ser::Serializer [] [src]

pub struct Serializer<W, F = CompactFormatter> {
    // some fields omitted
}

A structure for serializing Rust values into JSON.

Methods

impl<W> Serializer<W> where W: Write
[src]

fn new(writer: W) -> Self

Creates a new JSON serializer.

impl<'a, W> Serializer<W, PrettyFormatter<'a>> where W: Write
[src]

fn pretty(writer: W) -> Self

Creates a new JSON pretty print serializer.

impl<W, F> Serializer<W, F> where W: Write, F: Formatter
[src]

fn with_formatter(writer: W, formatter: F) -> Self

Creates a new JSON visitor whose output will be written to the writer specified.

fn into_inner(self) -> W

Unwrap the Writer from the Serializer.

Trait Implementations

impl<W, F> Serializer for Serializer<W, F> where W: Write, F: Formatter
[src]

type Error = Error

The error type that can be returned if some error occurs during serialization.

fn serialize_bool(&mut self, value: bool) -> Result<()>

Serializes a bool value.

fn serialize_isize(&mut self, value: isize) -> Result<()>

Serializes a isize value. By default it casts the value to a i64 and passes it to the serialize_i64 method. Read more

fn serialize_i8(&mut self, value: i8) -> Result<()>

Serializes a i8 value. By default it casts the value to a i64 and passes it to the serialize_i64 method. Read more

fn serialize_i16(&mut self, value: i16) -> Result<()>

Serializes a i16 value. By default it casts the value to a i64 and passes it to the serialize_i64 method. Read more

fn serialize_i32(&mut self, value: i32) -> Result<()>

Serializes a i32 value. By default it casts the value to a i64 and passes it to the serialize_i64 method. Read more

fn serialize_i64(&mut self, value: i64) -> Result<()>

Serializes a i64 value.

fn serialize_usize(&mut self, value: usize) -> Result<()>

Serializes a usize value. By default it casts the value to a u64 and passes it to the serialize_u64 method. Read more

fn serialize_u8(&mut self, value: u8) -> Result<()>

Serializes a u8 value. By default it casts the value to a u64 and passes it to the serialize_u64 method. Read more

fn serialize_u16(&mut self, value: u16) -> Result<()>

Serializes a u32 value. By default it casts the value to a u64 and passes it to the serialize_u64 method. Read more

fn serialize_u32(&mut self, value: u32) -> Result<()>

Serializes a u32 value. By default it casts the value to a u64 and passes it to the serialize_u64 method. Read more

fn serialize_u64(&mut self, value: u64) -> Result<()>

Serializes au64` value.

fn serialize_f32(&mut self, value: f32) -> Result<()>

Serializes a f32 value. By default it casts the value to a f64 and passes it to the serialize_f64 method. Read more

fn serialize_f64(&mut self, value: f64) -> Result<()>

Serializes a f64 value.

fn serialize_char(&mut self, value: char) -> Result<()>

Serializes a character. By default it serializes it as a &str containing a single character. Read more

fn serialize_str(&mut self, value: &str) -> Result<()>

Serializes a &str.

fn serialize_none(&mut self) -> Result<()>

Serializes a None value..serialize

fn serialize_some<V>(&mut self, value: V) -> Result<()> where V: Serialize

Serializes a Some(...) value.

fn serialize_unit(&mut self) -> Result<()>

Serializes a () value.

fn serialize_newtype_struct<T>(&mut self, _name: &'static str, value: T) -> Result<()> where T: Serialize

Override visit_newtype_struct to serialize newtypes without an object wrapper.

fn serialize_unit_variant(&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 serialize_newtype_variant<T>(&mut self, _name: &str, _variant_index: usize, variant: &str, value: T) -> Result<()> where T: Serialize

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 serialize_seq<V>(&mut self, visitor: V) -> Result<()> where V: SeqVisitor

Serializes a sequence. Read more

fn serialize_tuple_variant<V>(&mut self, _name: &str, _variant_index: usize, variant: &str, visitor: V) -> Result<()> where V: SeqVisitor

Serializes a tuple variant. Read more

fn serialize_seq_elt<T>(&mut self, value: T) -> Result<()> where T: Serialize

Serializes a sequence element.

fn serialize_map<V>(&mut self, visitor: V) -> Result<()> where V: MapVisitor

Serializes a map. Read more

fn serialize_struct_variant<V>(&mut self, _name: &str, _variant_index: usize, variant: &str, visitor: V) -> Result<()> where V: MapVisitor

Serializes a struct variant. Read more

fn serialize_map_elt<K, V>(&mut self, key: K, value: V) -> Result<()> where K: Serialize, V: Serialize

Serializes a map element (key-value pair).

fn serialize_bytes(&mut self, value: &[u8]) -> Result<(), Self::Error>

Enables those serialization formats that support serializing byte slices separately from generic arrays. By default it serializes as a regular array. Read more

fn serialize_unit_struct(&mut self, _name: &'static str) -> Result<(), Self::Error>

Serializes a unit struct value. Read more

fn serialize_tuple<V>(&mut self, visitor: V) -> Result<(), Self::Error> where V: SeqVisitor

Serializes a tuple. Read more

fn serialize_tuple_elt<T>(&mut self, value: T) -> Result<(), Self::Error> where T: Serialize

Serializes a tuple element. Read more

fn serialize_fixed_size_array<V>(&mut self, visitor: V) -> Result<(), Self::Error> where V: SeqVisitor

Serializes a fixed-size array. Read more

fn serialize_tuple_struct<V>(&mut self, _name: &'static str, visitor: V) -> Result<(), Self::Error> where V: SeqVisitor

Serializes a tuple struct. Read more

fn serialize_tuple_struct_elt<T>(&mut self, value: T) -> Result<(), Self::Error> where T: Serialize

Serializes a tuple struct element. Read more

fn serialize_tuple_variant_elt<T>(&mut self, value: T) -> Result<(), Self::Error> where T: Serialize

Serializes a tuple element. Read more

fn serialize_struct<V>(&mut self, _name: &'static str, visitor: V) -> Result<(), Self::Error> where V: MapVisitor

Serializes a struct. Read more

fn serialize_struct_elt<V>(&mut self, key: &'static str, value: V) -> Result<(), Self::Error> where V: Serialize

Serializes an element of a struct. Read more

fn serialize_struct_variant_elt<V>(&mut self, key: &'static str, value: V) -> Result<(), Self::Error> where V: Serialize

Serializes an element of a struct variant. Read more