pub struct JsonObject<Fields> { /* private fields */ }Expand description
a JSON Object (rfc8259) that wraps a mutable or immutable buffer of object fields. The easiest way to use it is through the ArrayJsonObject type alias, however you can use JsonObject directly to wrap your own buffer like a heap allocated Vec
Implementations§
Source§impl<'a, T: FieldBuffer<'a>> JsonObject<T>
impl<'a, T: FieldBuffer<'a>> JsonObject<T>
Source§impl<'a, T: FieldBufferMut<'a>> JsonObject<T>
impl<'a, T: FieldBufferMut<'a>> JsonObject<T>
Sourcepub fn fields_mut(&mut self) -> &mut [JsonField<'a, 'a>]
pub fn fields_mut(&mut self) -> &mut [JsonField<'a, 'a>]
get a mutable reference to the initialized fields
Sourcepub fn push<'x: 'a, 'y: 'a>(
&mut self,
field: JsonField<'x, 'y>,
) -> Result<(), JsonField<'x, 'y>>
pub fn push<'x: 'a, 'y: 'a>( &mut self, field: JsonField<'x, 'y>, ) -> Result<(), JsonField<'x, 'y>>
attempt to push a new field - returns the field if there is not enough space
Sourcepub fn pop(&mut self) -> Option<JsonField<'a, 'a>>
pub fn pop(&mut self) -> Option<JsonField<'a, 'a>>
attempt to pop an existing field - returns None if there are no initialized fields
Source§impl<'a, const N: usize> JsonObject<[JsonField<'a, 'a>; N]>
impl<'a, const N: usize> JsonObject<[JsonField<'a, 'a>; N]>
Sourcepub const fn push_const(
&mut self,
key: &'a str,
value: JsonValue<'a>,
) -> Result<(), ()>
pub const fn push_const( &mut self, key: &'a str, value: JsonValue<'a>, ) -> Result<(), ()>
similar to JsonObject::push but supports const contexts & only returns a reference
Sourcepub const fn pop_const(&mut self) -> Option<&JsonField<'a, 'a>>
pub const fn pop_const(&mut self) -> Option<&JsonField<'a, 'a>>
similar to JsonObject::pop but supports const contexts
Sourcepub fn new_parsed(data: &'a [u8]) -> Result<(usize, Self), JsonParseFailure>
pub fn new_parsed(data: &'a [u8]) -> Result<(usize, Self), JsonParseFailure>
convenience method to automatically create an ArrayJsonObject if object parsing is successful
Sourcepub const fn fields_const(&self) -> &[JsonField<'a, 'a>]
pub const fn fields_const(&self) -> &[JsonField<'a, 'a>]
same as JsonObject::fields but supports const contexts
Sourcepub const fn fields_mut_const(&mut self) -> &mut [JsonField<'a, 'a>]
pub const fn fields_mut_const(&mut self) -> &mut [JsonField<'a, 'a>]
same as JsonObject::fields_mut but supports const contexts