Skip to main content

JsonBackend

Trait JsonBackend 

Source
pub trait JsonBackend {
    type Output;

    // Required methods
    fn begin_array(&mut self) -> Result<()>;
    fn begin_object(&mut self) -> Result<()>;
    fn end_array(&mut self) -> Result<()>;
    fn end_object(&mut self) -> Result<()>;
    fn finish(self) -> Result<Self::Output>;
    fn write_bool(&mut self, b: bool) -> Result<()>;
    fn write_name(&mut self, name: &str) -> Result<()>;
    fn write_null(&mut self) -> Result<()>;
    fn write_number(&mut self, n: u32) -> Result<()>;
    fn write_string(&mut self, s: &str) -> Result<()>;
}
Expand description

Low-level JSON token emitter. Implementations write JSON tokens to an underlying sink. State validation is performed by crate::JsonEmitter, not by the backend.

Required Associated Types§

Source

type Output

Type returned by JsonBackend::finish.

Required Methods§

Source

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

Begin a JSON array (writes [).

§Errors

Returns any error produced by the underlying backend.

Source

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

Begin a JSON object (writes {).

§Errors

Returns any error produced by the underlying backend.

Source

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

End the current JSON array (writes ]).

§Errors

Returns any error produced by the underlying backend.

Source

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

End the current JSON object (writes }).

§Errors

Returns any error produced by the underlying backend.

Source

fn finish(self) -> Result<Self::Output>

Finish writing and return the backend’s output.

§Errors

Returns any error produced by the underlying backend.

Source

fn write_bool(&mut self, b: bool) -> Result<()>

Write a boolean value.

§Errors

Returns any error produced by the underlying backend.

Source

fn write_name(&mut self, name: &str) -> Result<()>

Write an object key.

§Errors

Returns any error produced by the underlying backend.

Source

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

Write a null value.

§Errors

Returns any error produced by the underlying backend.

Source

fn write_number(&mut self, n: u32) -> Result<()>

Write a u32 numeric value.

§Errors

Returns any error produced by the underlying backend.

Source

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

Write a string value.

§Errors

Returns any error produced by the underlying backend.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§