[][src]Struct sval_json::Formatter

pub struct Formatter<W> { /* fields omitted */ }

A stream for writing structured data as json.

The stream internally wraps a std::fmt::Write.

Examples

Create an owned json stream:

use sval::stream::OwnedStream;
use sval_json::Formatter;

let mut stream = OwnedStream::begin(Formatter::new(String::new()))?;
stream.any(42)?;
let json = stream.end()?.into_inner();

assert_eq!("42", json);

Methods

impl<W> Formatter<W> where
    W: Write
[src]

pub fn new(out: W) -> Self[src]

Create a new json stream.

pub fn into_inner(self) -> W[src]

Get the inner writer back out of the stream.

There is no validation done to ensure the data written is valid.

Trait Implementations

impl<W> Stream for Formatter<W> where
    W: Write
[src]

fn i128(&mut self, v: i128) -> Result<(), Error>[src]

Stream a 128bit signed integer.

fn u128(&mut self, v: u128) -> Result<(), Error>[src]

Stream a 128bit unsigned integer.

Auto Trait Implementations

impl<W> Send for Formatter<W> where
    W: Send

impl<W> Sync for Formatter<W> where
    W: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]