pub struct JsonbObject { /* private fields */ }Expand description
A JSON object with keys sorted for efficient lookup.
Implementations§
Source§impl JsonbObject
impl JsonbObject
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a JsonbObject with pre-allocated capacity.
Sourcepub fn get(&self, key: &str) -> Option<&JsonbValue>
pub fn get(&self, key: &str) -> Option<&JsonbValue>
Gets a value by key using binary search. O(log n)
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut JsonbValue>
pub fn get_mut(&mut self, key: &str) -> Option<&mut JsonbValue>
Gets a mutable value by key using binary search. O(log n)
Sourcepub fn insert(&mut self, key: String, value: JsonbValue)
pub fn insert(&mut self, key: String, value: JsonbValue)
Inserts a key-value pair, maintaining sorted order.
Sourcepub fn remove(&mut self, key: &str) -> Option<JsonbValue>
pub fn remove(&mut self, key: &str) -> Option<JsonbValue>
Removes a key and returns its value if present.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if the object contains the given key.
Sourcepub fn values(&self) -> impl Iterator<Item = &JsonbValue>
pub fn values(&self) -> impl Iterator<Item = &JsonbValue>
Returns an iterator over the values.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &JsonbValue)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &JsonbValue)>
Returns an iterator over key-value pairs.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (&str, &mut JsonbValue)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&str, &mut JsonbValue)>
Returns a mutable iterator over key-value pairs.
Trait Implementations§
Source§impl Clone for JsonbObject
impl Clone for JsonbObject
Source§fn clone(&self) -> JsonbObject
fn clone(&self) -> JsonbObject
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for JsonbObject
impl Debug for JsonbObject
Source§impl Default for JsonbObject
impl Default for JsonbObject
Source§fn default() -> JsonbObject
fn default() -> JsonbObject
Returns the “default value” for a type. Read more
Source§impl From<JsonbObject> for JsonbValue
impl From<JsonbObject> for JsonbValue
Source§fn from(v: JsonbObject) -> Self
fn from(v: JsonbObject) -> Self
Converts to this type from the input type.
Source§impl PartialEq for JsonbObject
impl PartialEq for JsonbObject
Auto Trait Implementations§
impl Freeze for JsonbObject
impl RefUnwindSafe for JsonbObject
impl Send for JsonbObject
impl Sync for JsonbObject
impl Unpin for JsonbObject
impl UnwindSafe for JsonbObject
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more