JsonArray

Struct JsonArray 

Source
pub struct JsonArray<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> { /* private fields */ }
Expand description

A JsonArray is the API for writing a JSON array, i.e. a sequence of elements. The closing ] is written when the JsonArray instance goes out of scope, or when its end() function is called.

For nested objects or arrays, the function calls return new JsonObject or JsonArray instances, respectively. Rust’s type system ensures that applications can only interact with the innermost such instance, and call outer instances only when all nested instances have gone out of scope.

A typical use of the library is to create a JsonWriter and then wrap it in a top-level JsonArray instance.

Implementations§

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn new(writer: &'a mut JsonWriter<'b, W, F, FF>) -> Result<Self, W::Error>

Create a new JsonArray instance. Application code can do this explicitly only initially as a starting point for writing JSON. Nested arrays are created by the library.

Source

pub fn write_string_value(&mut self, value: &str) -> Result<(), W::Error>

Write an element of type ‘string’, escaping the provided string value.

Source

pub fn write_bool_value(&mut self, value: bool) -> Result<(), W::Error>

Write an element of type ‘bool’.

Source

pub fn write_null_value(&mut self) -> Result<(), W::Error>

Write a null literal as an element.

Source

pub fn write_f64_value(&mut self, value: f64) -> Result<(), W::Error>

Write an f64 value as an element. If the value is not finite (i.e. infinite or NaN), a null literal is written instead. Different behavior (e.g. leaving out the element for non-finite numbers, representing them in some other way etc.) is the responsibility of application code.

Source

pub fn write_f32_value(&mut self, value: f32) -> Result<(), W::Error>

Write an f32 value as an element. If the value is not finite (i.e. infinite or NaN), a null literal is written instead. Different behavior (e.g. leaving out the element for non-finite numbers, representing them in some other way etc.) is the responsibility of application code.

Source

pub fn start_object<'c, 'x>( &'x mut self, ) -> Result<JsonObject<'c, 'b, W, F, FF>, W::Error>
where 'a: 'c, 'x: 'c,

Start a nested object as an element. This function returns a new JsonObject instance for writing elements to the nested object. When the returned JsonObject goes out of scope (per syntactic scope or an explicit call to end()), the nested object is closed, and application code can continue adding elements to the owning self object.

Source

pub fn start_array<'c, 'x>( &'x mut self, ) -> Result<JsonArray<'c, 'b, W, F, FF>, W::Error>
where 'a: 'c, 'x: 'c,

Start a nested array as an element. This function returns a new JsonArray instance for writing elements to the nested object. When the returned JsonArray goes out of scope (per syntactic scope or an explicit call to end()), the nested object is closed, and application code can continue adding elements to the owning self object.

Source

pub fn end(self) -> Result<(), W::Error>

Explicitly end this array’s lifetime and write the closing bracket.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_i8_value(&mut self, value: i8) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_u8_value(&mut self, value: u8) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_i16_value(&mut self, value: i16) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_u16_value(&mut self, value: u16) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_i32_value(&mut self, value: i32) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_u32_value(&mut self, value: u32) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_i64_value(&mut self, value: i64) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_u64_value(&mut self, value: u64) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_i128_value(&mut self, value: i128) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_u128_value(&mut self, value: u128) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_isize_value(&mut self, value: isize) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> JsonArray<'a, 'b, W, F, FF>

Source

pub fn write_usize_value(&mut self, value: usize) -> Result<(), W::Error>

Write an element with a generic int value. This function fits most Rust integral types; for the exceptions, there are separate functions.

Trait Implementations§

Source§

impl<'a, 'b, W: BlockingWrite, F: JsonFormatter, FF: FloatFormat> Drop for JsonArray<'a, 'b, W, F, FF>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, 'b, W, F, FF> Freeze for JsonArray<'a, 'b, W, F, FF>

§

impl<'a, 'b, W, F, FF> RefUnwindSafe for JsonArray<'a, 'b, W, F, FF>

§

impl<'a, 'b, W, F, FF> Send for JsonArray<'a, 'b, W, F, FF>
where F: Send, FF: Send, W: Send, <W as BlockingWrite>::Error: Send,

§

impl<'a, 'b, W, F, FF> Sync for JsonArray<'a, 'b, W, F, FF>
where F: Sync, FF: Sync, W: Sync, <W as BlockingWrite>::Error: Sync,

§

impl<'a, 'b, W, F, FF> Unpin for JsonArray<'a, 'b, W, F, FF>

§

impl<'a, 'b, W, F, FF> !UnwindSafe for JsonArray<'a, 'b, W, F, FF>

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.