pub struct JsonArray<Values> { /* private fields */ }Expand description
JsonObject represents an RFC 8259 JSON Array. It wraps a mutable or immutable buffer of JSON values. The easiest way to use it is through the ArrayJsonArray type alias, however you can use JsonArray directly to wrap your own buffer like a heap allocated Vec.
Implementations§
Source§impl<T> JsonArray<T>
impl<T> JsonArray<T>
Sourcepub fn into_inner(self) -> (T, usize)
pub fn into_inner(self) -> (T, usize)
consume this JsonObject to return (field buffer, num fields considered initialized)
Source§impl<'a, T: ValueBuffer<'a>> JsonArray<T>
impl<'a, T: ValueBuffer<'a>> JsonArray<T>
Sourcepub const fn wrap(values: T) -> Self
pub const fn wrap(values: T) -> Self
wrap a collection of values into a JsonArray and considers none of the values to be initialized
Sourcepub fn wrap_init(values: T) -> Self
pub fn wrap_init(values: T) -> Self
wrap a collection of fields into a JsonObject and considers all of the fields to be initialized
Sourcepub const fn len(&self) -> usize
pub const fn len(&self) -> usize
get the number of initialized values in this JsonArray. Same as self.values().len()
Sourcepub fn values(&self) -> &[JsonValue<'a>]
pub fn values(&self) -> &[JsonValue<'a>]
get an immutable reference to the initialized values of this JsonArray
Source§impl<'a, T: ValueBufferMut<'a>> JsonArray<T>
impl<'a, T: ValueBufferMut<'a>> JsonArray<T>
Sourcepub fn values_mut(&mut self) -> &mut [JsonValue<'a>]
pub fn values_mut(&mut self) -> &mut [JsonValue<'a>]
get a mutable reference to the initialized fields of this JsonObject
Sourcepub fn push<V: Into<JsonValue<'a>>>(&mut self, value: V) -> Result<(), ()>
pub fn push<V: Into<JsonValue<'a>>>(&mut self, value: V) -> Result<(), ()>
attempt to push a new field - fails if there is not enough space
Source§impl<'a, const N: usize> JsonArray<[JsonValue<'a>; N]>
impl<'a, const N: usize> JsonArray<[JsonValue<'a>; N]>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
convenience method to initialize a new array & call JsonObject::wrap on it
Sourcepub const fn push_const(&mut self, value: JsonValue<'a>) -> Result<(), ()>
pub const fn push_const(&mut self, value: JsonValue<'a>) -> Result<(), ()>
convenience method to automatically create an ArrayJsonObject if object parsing is successful similar to JsonObject::push but supports const contexts & only returns a reference
Sourcepub const fn pop_const(&mut self) -> Option<&JsonValue<'a>>
pub const fn pop_const(&mut self) -> Option<&JsonValue<'a>>
similar to JsonObject::pop but supports const contexts
Sourcepub const fn values_const(&self) -> &[JsonValue<'a>]
pub const fn values_const(&self) -> &[JsonValue<'a>]
same as JsonObject::fields but supports const contexts
Sourcepub const fn values_mut_const(&mut self) -> &mut [JsonValue<'a>]
pub const fn values_mut_const(&mut self) -> &mut [JsonValue<'a>]
same as JsonObject::fields_mut but supports const contexts