pub struct ArrayBuilder { /* private fields */ }Expand description
Fluent builder for a JSON array ([...]).
Nested objects/arrays are written in place into the same buffer.
Implementations§
Source§impl ArrayBuilder
impl ArrayBuilder
pub fn with_capacity(cap: usize) -> Self
Sourcepub fn item(self, value: &(impl ToJsonBytes + ?Sized)) -> Self
pub fn item(self, value: &(impl ToJsonBytes + ?Sized)) -> Self
Append a typed value.
Sourcepub fn item_opt<T: ToJsonBytes + ?Sized>(self, value: Option<&T>) -> Self
pub fn item_opt<T: ToJsonBytes + ?Sized>(self, value: Option<&T>) -> Self
Append value when Some.
Sourcepub fn object(self, build: impl FnOnce(ObjectBuilder) -> ObjectBuilder) -> Self
pub fn object(self, build: impl FnOnce(ObjectBuilder) -> ObjectBuilder) -> Self
Nested object element written in place.
Sourcepub fn array(self, build: impl FnOnce(ArrayBuilder) -> ArrayBuilder) -> Self
pub fn array(self, build: impl FnOnce(ArrayBuilder) -> ArrayBuilder) -> Self
Nested array element written in place.
Sourcepub fn extend<I, T>(self, iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
T: ToJsonBytes,
pub fn extend<I, T>(self, iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
T: ToJsonBytes,
Append all items from an iterator.
Sourcepub fn finish_into(self, out: &mut Vec<u8>)
pub fn finish_into(self, out: &mut Vec<u8>)
Append the finished array onto out.
pub fn len(&self) -> usize
Trait Implementations§
Source§impl Clone for ArrayBuilder
impl Clone for ArrayBuilder
Source§fn clone(&self) -> ArrayBuilder
fn clone(&self) -> ArrayBuilder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ArrayBuilder
impl Debug for ArrayBuilder
Source§impl Default for ArrayBuilder
impl Default for ArrayBuilder
Source§impl ToJsonBytes for ArrayBuilder
impl ToJsonBytes for ArrayBuilder
Source§fn to_json_bytes(&self) -> Vec<u8> ⓘ
fn to_json_bytes(&self) -> Vec<u8> ⓘ
Serializes the value into a raw JSON byte vector. Read more
Source§fn write_json_bytes(&self, out: &mut Vec<u8>)
fn write_json_bytes(&self, out: &mut Vec<u8>)
Append the JSON encoding of
self into out (avoids an intermediate Vec
when the implementor overrides this; default uses to_json_bytes).Auto Trait Implementations§
impl Freeze for ArrayBuilder
impl RefUnwindSafe for ArrayBuilder
impl Send for ArrayBuilder
impl Sync for ArrayBuilder
impl Unpin for ArrayBuilder
impl UnsafeUnpin for ArrayBuilder
impl UnwindSafe for ArrayBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more