[][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::new(Formatter::new(String::new()));
stream.any(42)?;
let json = stream.into_inner().end()?;

assert_eq!("42", json);

Implementations

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

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

Create a new json stream.

pub fn is_valid(&self) -> bool[src]

Whether the stream has seen a complete, valid json structure.

pub fn end(self) -> Result<W, End<Self>>[src]

Complete the stream and return the inner writer.

If the writer contains incomplete json then this method will fail. The returned error can be used to pull the original stream back out.

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

Get the inner writer back out of the stream without ensuring it's valid.

Trait Implementations

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

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.