Struct json_writer::JSONArrayWriter
source · pub struct JSONArrayWriter<'a> {
pub buffer: &'a mut String,
/* private fields */
}Expand description
Helper for appending a JSON array to the borrowed buffer.
Appends ‘[’ on creation. Appends ‘]’ when dropped.
Fields§
§buffer: &'a mut StringMutable 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 JSONArrayWriter<'_>
impl JSONArrayWriter<'_>
sourcepub fn new<'a>(buffer: &'a mut String) -> JSONArrayWriter<'a>
pub fn new<'a>(buffer: &'a mut String) -> JSONArrayWriter<'a>
Creates a new JSONArrayWriter that writes to the given buffer. Writes ‘[’ to the buffer immediately.
sourcepub fn object<'a>(&'a mut self) -> JSONObjectWriter<'a>
pub fn object<'a>(&'a mut self) -> JSONObjectWriter<'a>
Starts writing a nested object as array entry.
Writes ‘{’ and returns a JSONObjectWriter
sourcepub fn array<'a>(&'a mut self) -> JSONArrayWriter<'a>
pub fn array<'a>(&'a mut self) -> JSONArrayWriter<'a>
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.
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