[−][src]Struct sval_json::Writer
A stream for writing structured data as json.
The stream internally wraps a std::io::Write
.
Examples
Create an owned json stream:
use sval::stream::OwnedStream; use sval_json::Writer; let mut stream = OwnedStream::new(Writer::new(Vec::<u8>::new())); stream.any(42)?; let json = stream.into_inner().end()?; assert_eq!(Some("42"), str::from_utf8(&json).ok());
Methods
impl<W> Writer<W> where
W: Write,
[src]
W: Write,
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 Writer<W> where
W: Write,
[src]
W: Write,
fn fmt(&mut self, v: Arguments) -> Result
[src]
fn i64(&mut self, v: i64) -> Result
[src]
fn u64(&mut self, v: u64) -> Result
[src]
fn f64(&mut self, v: f64) -> Result
[src]
fn bool(&mut self, v: bool) -> Result
[src]
fn char(&mut self, v: char) -> Result
[src]
fn str(&mut self, v: &str) -> Result
[src]
fn none(&mut self) -> Result
[src]
fn seq_begin(&mut self, len: Option<usize>) -> Result
[src]
fn seq_elem(&mut self) -> Result
[src]
fn seq_end(&mut self) -> Result
[src]
fn map_begin(&mut self, len: Option<usize>) -> Result
[src]
fn map_key(&mut self) -> Result
[src]
fn map_value(&mut self) -> Result
[src]
fn map_end(&mut self) -> Result
[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> Unpin for Writer<W> where
W: Unpin,
W: Unpin,
impl<W> Sync for Writer<W> where
W: Sync,
W: Sync,
impl<W> Send for Writer<W> where
W: Send,
W: Send,
impl<W> UnwindSafe for Writer<W> where
W: UnwindSafe,
W: UnwindSafe,
impl<W> RefUnwindSafe for Writer<W> where
W: RefUnwindSafe,
W: RefUnwindSafe,
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,