pub struct Encoder<'a> { /* private fields */ }
Expand description
A structure for implementing serialization to JSON.
Implementations§
Source§impl<'a> Encoder<'a>
impl<'a> Encoder<'a>
Sourcepub fn new_pretty(writer: &'a mut dyn Write) -> Encoder<'a>
pub fn new_pretty(writer: &'a mut dyn Write) -> Encoder<'a>
Creates a new encoder whose output will be written in human-readable JSON to the specified writer
Trait Implementations§
Source§impl<'a> Encoder for Encoder<'a>
impl<'a> Encoder for Encoder<'a>
Source§type Error = EncoderError
type Error = EncoderError
The error type for method results.
Source§fn emit_usize(&mut self, v: usize) -> EncodeResult<()>
fn emit_usize(&mut self, v: usize) -> EncodeResult<()>
Emit a usize value.
Source§fn emit_isize(&mut self, v: isize) -> EncodeResult<()>
fn emit_isize(&mut self, v: isize) -> EncodeResult<()>
Emit a isize value.
Source§fn emit_enum<F>(&mut self, _name: &str, f: F) -> EncodeResult<()>
fn emit_enum<F>(&mut self, _name: &str, f: F) -> EncodeResult<()>
Emit an enumeration value. Read more
Source§fn emit_enum_variant<F>(
&mut self,
name: &str,
_id: usize,
cnt: usize,
f: F,
) -> EncodeResult<()>
fn emit_enum_variant<F>( &mut self, name: &str, _id: usize, cnt: usize, f: F, ) -> EncodeResult<()>
Emit a enumeration variant value with no or unnamed data. Read more
Source§fn emit_enum_variant_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()>
fn emit_enum_variant_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()>
Emit an unnamed data item for an enumeration variant. Read more
Source§fn emit_enum_struct_variant<F>(
&mut self,
name: &str,
id: usize,
cnt: usize,
f: F,
) -> EncodeResult<()>
fn emit_enum_struct_variant<F>( &mut self, name: &str, id: usize, cnt: usize, f: F, ) -> EncodeResult<()>
Emit a enumeration variant value with no or named data. Read more
Source§fn emit_enum_struct_variant_field<F>(
&mut self,
_: &str,
idx: usize,
f: F,
) -> EncodeResult<()>
fn emit_enum_struct_variant_field<F>( &mut self, _: &str, idx: usize, f: F, ) -> EncodeResult<()>
Emit a named data item for an enumeration variant. Read more
Source§fn emit_struct<F>(&mut self, _: &str, len: usize, f: F) -> EncodeResult<()>
fn emit_struct<F>(&mut self, _: &str, len: usize, f: F) -> EncodeResult<()>
Emit a struct value. Read more
Source§fn emit_struct_field<F>(
&mut self,
name: &str,
idx: usize,
f: F,
) -> EncodeResult<()>
fn emit_struct_field<F>( &mut self, name: &str, idx: usize, f: F, ) -> EncodeResult<()>
Emit a field item for a struct. Read more
Source§fn emit_tuple<F>(&mut self, len: usize, f: F) -> EncodeResult<()>
fn emit_tuple<F>(&mut self, len: usize, f: F) -> EncodeResult<()>
Emit a tuple value. Read more
Source§fn emit_tuple_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()>
fn emit_tuple_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()>
Emit a data item for a tuple. Read more
Source§fn emit_tuple_struct<F>(
&mut self,
_: &str,
len: usize,
f: F,
) -> EncodeResult<()>
fn emit_tuple_struct<F>( &mut self, _: &str, len: usize, f: F, ) -> EncodeResult<()>
Emit a tuple struct value. Read more
Source§fn emit_tuple_struct_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()>
fn emit_tuple_struct_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()>
Emit a data item for a tuple struct. Read more
Source§fn emit_option<F>(&mut self, f: F) -> EncodeResult<()>
fn emit_option<F>(&mut self, f: F) -> EncodeResult<()>
Emit an optional value. Read more
Source§fn emit_option_none(&mut self) -> EncodeResult<()>
fn emit_option_none(&mut self) -> EncodeResult<()>
Emit the
None
optional value. Read moreSource§fn emit_option_some<F>(&mut self, f: F) -> EncodeResult<()>
fn emit_option_some<F>(&mut self, f: F) -> EncodeResult<()>
Emit the
Some(x)
optional value. Read moreSource§fn emit_seq<F>(&mut self, len: usize, f: F) -> EncodeResult<()>
fn emit_seq<F>(&mut self, len: usize, f: F) -> EncodeResult<()>
Emit a sequence of values. Read more
Source§fn emit_seq_elt<F>(&mut self, idx: usize, f: F) -> EncodeResult<()>
fn emit_seq_elt<F>(&mut self, idx: usize, f: F) -> EncodeResult<()>
Emit an element in a sequence. Read more
Source§fn emit_map<F>(&mut self, len: usize, f: F) -> EncodeResult<()>
fn emit_map<F>(&mut self, len: usize, f: F) -> EncodeResult<()>
Emit an associative container (map). Read more
Source§fn emit_map_elt_key<F>(&mut self, idx: usize, f: F) -> EncodeResult<()>
fn emit_map_elt_key<F>(&mut self, idx: usize, f: F) -> EncodeResult<()>
Emit the key for an entry in a map. Read more
Source§fn emit_map_elt_val<F>(&mut self, _idx: usize, f: F) -> EncodeResult<()>
fn emit_map_elt_val<F>(&mut self, _idx: usize, f: F) -> EncodeResult<()>
Emit the value for an entry in a map. Read more
Auto Trait Implementations§
impl<'a> Freeze for Encoder<'a>
impl<'a> !RefUnwindSafe for Encoder<'a>
impl<'a> !Send for Encoder<'a>
impl<'a> !Sync for Encoder<'a>
impl<'a> Unpin for Encoder<'a>
impl<'a> !UnwindSafe for Encoder<'a>
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