JsonStreamWriter

Struct JsonStreamWriter 

Source
pub struct JsonStreamWriter<W>
where W: Write,
{ /* private fields */ }
Expand description

A JSON writer implementation which writes data to a Write

This writer internally buffers data so it is normally not necessary to wrap the provided writer in a std::io::BufWriter.

The data written to the underlying writer will be valid UTF-8 data if the JSON document is finished properly by calling JsonWriter::finish_document. No leading byte order mark (BOM) is written.

If the underlying writer returns an error of kind ErrorKind::Interrupted, this JSON writer will keep retrying to write the data.

Implementations§

Source§

impl<W> JsonStreamWriter<W>
where W: Write,

Source

pub fn new(writer: W) -> JsonStreamWriter<W>

Creates a JSON writer with default settings

Source

pub fn new_custom( writer: W, writer_settings: WriterSettings, ) -> JsonStreamWriter<W>

Creates a JSON writer with custom settings

The settings can be used to customize how the JSON output will look like.

Trait Implementations§

Source§

impl<W> Debug for JsonStreamWriter<W>
where W: Write + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<W> JsonWriter for JsonStreamWriter<W>
where W: Write,

Source§

type WriterResult = W

Result returned by finish_document

This JSON writer implementation returns the underlying Write to allow for example to reuse it for other purposes. However, the JSON document is already written during JSON writer usage, so the returned Write can be ignored in case it is not needed for anything else.

Source§

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

Begins writing a JSON object Read more
Source§

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

Writes the name of the next JSON object member Read more
Source§

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

Writes the closing bracket } of the current JSON object Read more
Source§

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

Begins writing a JSON array Read more
Source§

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

Writes the closing bracket ] of the current JSON object Read more
Source§

fn string_value(&mut self, value: &str) -> Result<(), Error>

Writes a JSON string value Read more
Source§

fn bool_value(&mut self, value: bool) -> Result<(), Error>

Writes a JSON boolean value Read more
Source§

fn null_value(&mut self) -> Result<(), Error>

Writes a JSON null value Read more
Source§

fn number_value<N>(&mut self, value: N) -> Result<(), Error>
where N: FiniteNumber,

Writes a finite JSON number value Read more
Source§

fn fp_number_value<N>(&mut self, value: N) -> Result<(), JsonNumberError>

Writes a floating point JSON number value Read more
Source§

fn number_value_from_string( &mut self, value: &str, ) -> Result<(), JsonNumberError>

Writes the string representation of a JSON number value Read more
Source§

fn finish_document( self, ) -> Result<<JsonStreamWriter<W> as JsonWriter>::WriterResult, Error>

Verifies that the JSON document is complete and flushes the buffer Read more
Source§

fn string_value_writer(&mut self) -> Result<impl StringValueWriter, Error>

Provides a writer for lazily writing a JSON string value Read more

Auto Trait Implementations§

§

impl<W> Freeze for JsonStreamWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for JsonStreamWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for JsonStreamWriter<W>
where W: Send,

§

impl<W> Sync for JsonStreamWriter<W>
where W: Sync,

§

impl<W> Unpin for JsonStreamWriter<W>
where W: Unpin,

§

impl<W> UnwindSafe for JsonStreamWriter<W>
where W: 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more