pub use simd_json_derive_int::*;
use std::collections;
use std::io::{self, Write};
use value_trait::generator::BaseGenerator;
mod impls;
pub type Result = io::Result<()>;
pub trait Serialize {
fn json_write<W>(&self, writer: &mut W) -> Result
where
W: Write;
#[inline]
fn json_vec(&self) -> io::Result<Vec<u8>> {
let mut v = Vec::with_capacity(512);
self.json_write(&mut v)?;
Ok(v)
}
#[inline]
fn json_string(&self) -> io::Result<String> {
self.json_vec()
.map(|v| unsafe { String::from_utf8_unchecked(v) })
}
}
struct DummyGenerator<W: Write>(W);
impl<W: Write> BaseGenerator for DummyGenerator<W> {
type T = W;
#[inline]
fn get_writer(&mut self) -> &mut <Self as BaseGenerator>::T {
&mut self.0
}
#[inline]
fn write_min(&mut self, _: &[u8], _: u8) -> io::Result<()> {
unimplemented!()
}
}