JsonWrite

Trait JsonWrite 

Source
pub trait JsonWrite: Write {
    // Provided methods
    fn open_object(&mut self) -> Result { ... }
    fn close_object(&mut self) -> Result { ... }
    fn open_array(&mut self) -> Result { ... }
    fn close_array(&mut self) -> Result { ... }
    fn keyval_sep(&mut self) -> Result { ... }
    fn key(&mut self, value: impl WriteJsonKey) -> Result { ... }
    fn value(&mut self, value: impl WriteJsonValue) -> Result { ... }
    fn val_sep(&mut self) -> Result { ... }
    fn space(&mut self) -> Result { ... }
    fn newline(&mut self) -> Result { ... }
}

Provided Methods§

Source

fn open_object(&mut self) -> Result

Source

fn close_object(&mut self) -> Result

Source

fn open_array(&mut self) -> Result

Source

fn close_array(&mut self) -> Result

Source

fn keyval_sep(&mut self) -> Result

Source

fn key(&mut self, value: impl WriteJsonKey) -> Result

Write an encoded JSON key

Source

fn value(&mut self, value: impl WriteJsonValue) -> Result

Write an encoded JSON scalar value

For floats, this preserves the sign bit for f32::NAN / f64::NAN for the sake of format-preserving editing. However, in most cases the sign bit is indeterminate and outputting signed NANs can be a cause of non-repeatable behavior.

For general serialization, you should discard the sign bit. For example:

if v.is_nan() {
    v = v.copysign(1.0);
}
Source

fn val_sep(&mut self) -> Result

Source

fn space(&mut self) -> Result

Source

fn newline(&mut self) -> Result

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<W> JsonWrite for W
where W: Write,