Trait Generator

Source
pub trait Generator {
    type T: Write;

    // Required methods
    fn get_writer(&mut self) -> &mut Self::T;
    fn write_min(&mut self, slice: &[u8], min: u8) -> Result<()>;

    // Provided methods
    fn write(&mut self, slice: &[u8]) -> Result<()> { ... }
    fn write_char(&mut self, ch: u8) -> Result<()> { ... }
    fn new_line(&mut self) -> Result<()> { ... }
    fn indent(&mut self) { ... }
    fn dedent(&mut self) { ... }
    fn write_string_complex(&mut self, string: &str, start: usize) -> Result<()> { ... }
    fn write_string(&mut self, string: &str) -> Result<()> { ... }
    fn write_number(&mut self, num: &Number) -> Result<()> { ... }
    fn write_object(&mut self, object: &Object) -> Result<()> { ... }
    fn write_json(&mut self, json: &JsonValue) -> Result<()> { ... }
}
Expand description

Default trait for serializing JSONValue into string.

Required Associated Types§

Required Methods§

Source

fn get_writer(&mut self) -> &mut Self::T

Source

fn write_min(&mut self, slice: &[u8], min: u8) -> Result<()>

Provided Methods§

Source

fn write(&mut self, slice: &[u8]) -> Result<()>

Source

fn write_char(&mut self, ch: u8) -> Result<()>

Source

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

Source

fn indent(&mut self)

Source

fn dedent(&mut self)

Source

fn write_string_complex(&mut self, string: &str, start: usize) -> Result<()>

Source

fn write_string(&mut self, string: &str) -> Result<()>

Source

fn write_number(&mut self, num: &Number) -> Result<()>

Source

fn write_object(&mut self, object: &Object) -> Result<()>

Source

fn write_json(&mut self, json: &JsonValue) -> Result<()>

Implementors§

Source§

impl Generator for DumpGenerator

Source§

type T = Vec<u8>

Source§

impl Generator for PrettyGenerator

Source§

type T = Vec<u8>

Source§

impl<'a, W> Generator for PrettyWriterGenerator<'a, W>
where W: Write,

Source§

type T = W

Source§

impl<'a, W> Generator for WriterGenerator<'a, W>
where W: Write,

Source§

type T = W