Struct json_writer::JSONArrayWriter
source · pub struct JSONArrayWriter<'a, Writer: JSONWriter = String> {
pub writer: &'a mut Writer,
/* private fields */
}Expand description
Helper for appending a JSON array to the borrowed buffer.
Appends ‘[’ on creation. Appends ‘]’ when dropped.
Fields§
§writer: &'a mut WriterMutable borrow of buffer
Consider using the methods instead of using this field directly. This field should not be used unless you know what you are doing.
Implementations§
source§impl<W: JSONWriter> JSONArrayWriter<'_, W>
impl<W: JSONWriter> JSONArrayWriter<'_, W>
sourcepub fn new<'a>(writer: &'a mut W) -> JSONArrayWriter<'a, W>
pub fn new<'a>(writer: &'a mut W) -> JSONArrayWriter<'a, W>
Creates a new JSONArrayWriter that writes to the given buffer. Writes ‘[’ to the buffer immediately.
sourcepub fn object<'a>(&'a mut self) -> JSONObjectWriter<'a, W>
pub fn object<'a>(&'a mut self) -> JSONObjectWriter<'a, W>
Starts writing a nested object as array entry.
Writes ‘{’ and returns a JSONObjectWriter
sourcepub fn array<'a>(&'a mut self) -> JSONArrayWriter<'a, W>
pub fn array<'a>(&'a mut self) -> JSONArrayWriter<'a, W>
Starts writing a nested array as array entry.
Writes ‘[’ and returns a JSONArrayWriter
sourcepub fn value<T: JSONWriterValue>(&mut self, value: T)
pub fn value<T: JSONWriterValue>(&mut self, value: T)
Writes given value as array entry
sourcepub fn write_comma(&mut self)
pub fn write_comma(&mut self)
Writes a comma unless at the beginning of the array
Warning: If you use this method, you will have to write the value to the buffer youself afterwards.
source§impl JSONArrayWriter<'_, String>
impl JSONArrayWriter<'_, String>
sourcepub fn output_buffered_data<Writer: Write>(
&mut self,
writer: &mut Writer
) -> Result<usize, Error>
pub fn output_buffered_data<Writer: Write>( &mut self, writer: &mut Writer ) -> Result<usize, Error>
Writes the entire buffer to given writer and clears entire buffer on success.
sourcepub fn buffer_len(&self) -> usize
pub fn buffer_len(&self) -> usize
Returns buffer length in bytes