Skip to main content

FormatWriter

Trait FormatWriter 

Source
pub trait FormatWriter {
    // Required methods
    fn write(&self, value: &Value) -> Result<String>;
    fn write_to_writer(&self, value: &Value, writer: impl Write) -> Result<()>;
}
Expand description

Trait for writing a Value to a data format.

Implement this trait to add support for writing a new data format.

Required Methods§

Source

fn write(&self, value: &Value) -> Result<String>

Serialize the given Value and return the formatted string.

Source

fn write_to_writer(&self, value: &Value, writer: impl Write) -> Result<()>

Serialize the given Value and write to an io::Write destination.

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§