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§
Sourcetype Output
type Output
Type returned by JsonBackend::finish.
Required Methods§
Sourcefn begin_array(&mut self) -> Result<()>
fn begin_array(&mut self) -> Result<()>
Sourcefn begin_object(&mut self) -> Result<()>
fn begin_object(&mut self) -> Result<()>
Sourcefn end_array(&mut self) -> Result<()>
fn end_array(&mut self) -> Result<()>
End the current JSON array (writes ]).
§Errors
Returns any error produced by the underlying backend.
Sourcefn end_object(&mut self) -> Result<()>
fn end_object(&mut self) -> Result<()>
End the current JSON object (writes }).
§Errors
Returns any error produced by the underlying backend.
Sourcefn finish(self) -> Result<Self::Output>
fn finish(self) -> Result<Self::Output>
Finish writing and return the backend’s output.
§Errors
Returns any error produced by the underlying backend.
Sourcefn write_bool(&mut self, b: bool) -> Result<()>
fn write_bool(&mut self, b: bool) -> Result<()>
Sourcefn write_name(&mut self, name: &str) -> Result<()>
fn write_name(&mut self, name: &str) -> Result<()>
Sourcefn write_null(&mut self) -> Result<()>
fn write_null(&mut self) -> Result<()>
Sourcefn write_number(&mut self, n: u32) -> Result<()>
fn write_number(&mut self, n: u32) -> Result<()>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".