Skip to main content

JsonRenderer

Struct JsonRenderer 

Source
pub struct JsonRenderer<O: TextOut> { /* private fields */ }
Expand description

Renders JsonEvents/1 as JSON text.

Exactly one root value, then End; a second root, an End before the root or with a container open, a key outside an object or where a value is due, a value where a key is due, an unbalanced or mismatched close, and any event after End are PROTOCOL_ORDER_ERROR. Numbers write their lexeme when it is a JSON number (INVALID_NUMBER otherwise) and the shortest text that reads back as the value when there is none; NaN and infinity have no JSON form and are TARGET_VALUE_UNREPRESENTABLE, whatever lexeme stands beside them. A number is checked before its separator is written, so a rejected value leaves no trace. The output is flushed once, at End; a failure found after any text was written says so with committed_output.

Implementations§

Source§

impl<O: TextOut> JsonRenderer<O>

Source

pub fn new(out: O, options: JsonOptions) -> Self

Source

pub fn options(&self) -> &JsonOptions

Source

pub fn depth(&self) -> usize

Containers currently open.

Source

pub fn is_done(&self) -> bool

Whether End has been rendered.

Source

pub fn into_inner(self) -> O

Trait Implementations§

Source§

impl<O: TextOut> Sink for JsonRenderer<O>

Source§

fn event(&mut self, ev: JsonEvent<'_>) -> Result<Flow, Fail>

One event. An Err aborts the run; the source stops the parse and the error reaches the caller unchanged.

Auto Trait Implementations§

§

impl<O> Freeze for JsonRenderer<O>
where O: Freeze,

§

impl<O> RefUnwindSafe for JsonRenderer<O>
where O: RefUnwindSafe,

§

impl<O> Send for JsonRenderer<O>
where O: Send,

§

impl<O> Sync for JsonRenderer<O>
where O: Sync,

§

impl<O> Unpin for JsonRenderer<O>
where O: Unpin,

§

impl<O> UnsafeUnpin for JsonRenderer<O>
where O: UnsafeUnpin,

§

impl<O> UnwindSafe for JsonRenderer<O>
where O: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.