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 Writer
Mutable 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(writer: &mut W) -> JSONArrayWriter<'_, W>
pub fn new(writer: &mut W) -> JSONArrayWriter<'_, W>
Creates a new JSONArrayWriter that writes to the given buffer. Writes ‘[’ to the buffer immediately.
Sourcepub fn object(&mut self) -> JSONObjectWriter<'_, W>
pub fn object(&mut self) -> JSONObjectWriter<'_, W>
Starts writing a nested object as array entry.
Writes ‘{’ and returns a JSONObjectWriter
Sourcepub fn array(&mut self) -> JSONArrayWriter<'_, W>
pub fn array(&mut self) -> JSONArrayWriter<'_, 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 string_writer(&mut self) -> JSONStringWriter<'_, W>
pub fn string_writer(&mut self) -> JSONStringWriter<'_, W>
Write string with the given key, where the body of the string is built up using the
JSONStringWriter
that impls the fmt::Write
trait and so can be used in the write!
macro.
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 yourself 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