Skip to main content

ArrayBuilder

Struct ArrayBuilder 

Source
pub struct ArrayBuilder<'a, S: Sink> { /* private fields */ }
Expand description

Handle for a nested array. Closes on drop; call .end()? instead to surface close errors as a Result.

Implementations§

Source§

impl<'a, S: Sink> ArrayBuilder<'a, S>

Source

pub fn push_null(&mut self) -> Result<(), WriteError>

Append null.

Source

pub fn push_bool(&mut self, v: bool) -> Result<(), WriteError>

Append a boolean.

Source

pub fn push_i64(&mut self, v: i64) -> Result<(), WriteError>

Append a signed 64-bit integer.

Source

pub fn push_u64(&mut self, v: u64) -> Result<(), WriteError>

Append an unsigned 64-bit integer.

Source

pub fn push_f64(&mut self, v: f64) -> Result<(), WriteError>

Append a 64-bit float. Returns WriteError::NaNOrInfinity for NaN or ±∞.

Source

pub fn push_str(&mut self, s: &str) -> Result<(), WriteError>

Append a UTF-8 string.

Source

pub fn bytes_written(&self) -> u64

Source

pub fn buffered_bytes(&self) -> usize

Source

pub fn start_array<'b>(&'b mut self) -> ArrayBuilder<'b, S>

Open a nested array.

Source

pub fn start_object<'b>(&'b mut self) -> ObjectBuilder<'b, S>

Open a nested object.

Source

pub fn end(self) -> Result<(), WriteError>

Explicitly close the array, surfacing any close error.

Source§

impl<S: RewindableSink> ArrayBuilder<'_, S>

Source

pub fn try_write<F, T, E>(&mut self, f: F) -> Result<T, E>
where F: FnOnce(&mut Self) -> Result<T, E>, E: From<WriteError>,

Trait Implementations§

Source§

impl<S: Sink> Drop for ArrayBuilder<'_, S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for ArrayBuilder<'a, S>

§

impl<'a, S> RefUnwindSafe for ArrayBuilder<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for ArrayBuilder<'a, S>
where S: Send,

§

impl<'a, S> Sync for ArrayBuilder<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for ArrayBuilder<'a, S>

§

impl<'a, S> UnsafeUnpin for ArrayBuilder<'a, S>

§

impl<'a, S> !UnwindSafe for ArrayBuilder<'a, S>

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.