Skip to main content

JsonSerializer

Struct JsonSerializer 

Source
pub struct JsonSerializer<'a, const DEPTH: usize> { /* private fields */ }
Expand description

Streaming JSON serializer that writes into caller-owned fixed storage.

The serializer never allocates. DEPTH is the maximum number of open arrays/objects tracked by the internal stack.

Implementations§

Source§

impl<'a, const DEPTH: usize> JsonSerializer<'a, DEPTH>

Source

pub fn new(out: &'a mut [u8]) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn capacity(&self) -> usize

Source

pub fn as_str(&self) -> &str

Source

pub fn finish(&self) -> Result<&str>

Source

pub fn reset(&mut self)

Source

pub fn begin_object(&mut self) -> Result<()>

Source

pub fn end_object(&mut self) -> Result<()>

Source

pub fn begin_array(&mut self) -> Result<()>

Source

pub fn end_array(&mut self) -> Result<()>

Source

pub fn key(&mut self, key: &str) -> Result<()>

Source

pub fn null(&mut self) -> Result<()>

Source

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

Source

pub fn string(&mut self, value: &str) -> Result<()>

Source

pub fn i16(&mut self, value: i16) -> Result<()>

Source

pub fn u16(&mut self, value: u16) -> Result<()>

Source

pub fn i32(&mut self, value: i32) -> Result<()>

Source

pub fn u32(&mut self, value: u32) -> Result<()>

Source

pub fn i64(&mut self, value: i64) -> Result<()>

Source

pub fn u64(&mut self, value: u64) -> Result<()>

Source

pub fn f64(&mut self, value: f64) -> Result<()>

Source

pub fn raw_number(&mut self, number: &str) -> Result<()>

Trait Implementations§

Source§

impl<const DEPTH: usize> Write for JsonSerializer<'_, DEPTH>

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

§

impl<'a, const DEPTH: usize> Freeze for JsonSerializer<'a, DEPTH>

§

impl<'a, const DEPTH: usize> RefUnwindSafe for JsonSerializer<'a, DEPTH>

§

impl<'a, const DEPTH: usize> Send for JsonSerializer<'a, DEPTH>

§

impl<'a, const DEPTH: usize> Sync for JsonSerializer<'a, DEPTH>

§

impl<'a, const DEPTH: usize> Unpin for JsonSerializer<'a, DEPTH>

§

impl<'a, const DEPTH: usize> UnsafeUnpin for JsonSerializer<'a, DEPTH>

§

impl<'a, const DEPTH: usize> !UnwindSafe for JsonSerializer<'a, DEPTH>

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, 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.