Enum valu3::types::object::Object

source ·
pub enum Object {
    BTreeMap(BTreeMap<ValueKey, Value>),
    HashMap(HashMap<ValueKey, Value>),
}
Expand description

An enum representing a JSON object as a BTreeMap or a HashMap.

Variants§

Implementations§

source§

impl Object

source

pub fn get<T>(&self, key: T) -> Option<&Value>

Returns a reference to the value associated with the specified key, or None if the key is not present.

source

pub fn get_mut<T>(&mut self, key: T) -> Option<&mut Value>

source

pub fn clean(&mut self)

Removes all key-value pairs from the object.

source

pub fn insert<T>(&mut self, key: T, value: Value) -> Option<Value>

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source§

impl<'a> Object

source

pub fn iter(&'a self) -> ObjectIter<'a>

Trait Implementations§

source§

impl Clone for Object

source§

fn clone(&self) -> Object

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Object

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Object

source§

fn default() -> Self

Creates a new Object with an empty HashMap.

source§

impl<T, V> From<BTreeMap<T, V>> for Object

source§

fn from(value: BTreeMap<T, V>) -> Self

Converts BTreeMap<ValueKey, Value> into Object.

source§

impl<T, V> From<HashMap<T, V>> for Object

source§

fn from(value: HashMap<T, V>) -> Self

Converts BTreeMap<ValueKey, Value> into Object.

source§

impl From<HashMap<ValueKey, Value>> for Object

source§

fn from(value: HashMap<ValueKey, Value>) -> Self

Converts HashMap<ValueKey, Value> into Object.

source§

impl<T, V> From<Vec<(T, V)>> for Object

source§

fn from(value: Vec<(T, V)>) -> Self

Converts a vector of key-value pairs into an Object.

source§

impl From<Vec<(ValueKey, Value)>> for Object

source§

fn from(value: Vec<(ValueKey, Value)>) -> Self

Converts a vector of key-value pairs into an Object.

source§

impl Into<BTreeMap<ValueKey, Value>> for Object

source§

fn into(self) -> BTreeMap<ValueKey, Value>

Converts Object into BTreeMap<ValueKey, Value>.

source§

impl Into<HashMap<ValueKey, Value>> for Object

source§

fn into(self) -> HashMap<ValueKey, Value>

Converts Object into HashMap<ValueKey, Value>.

source§

impl ObjectBehavior for Object

source§

fn remove<T>(&mut self, key: &T) -> Option<Value>

Removes a key-value pair from the object and returns the associated value. If the key is not present, returns None.
source§

fn contains_key<T>(&self, key: &T) -> bool

Returns true if the object contains a value for the specified key, otherwise false.
source§

fn keys(&self) -> Vec<&ValueKey>

Returns a Vec of references to the keys in the object, in the order they were inserted.
source§

fn values(&self) -> Vec<&Value>

Returns a Vec of references to the values in the object, in the order they were inserted.
source§

impl PartialEq for Object

source§

fn eq(&self, other: &Object) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Object

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl ToValueBehavior for Object

source§

fn to_value(&self) -> Value

Converts a type into a Value.
source§

impl PrimitiveType for Object

source§

impl StructuralPartialEq for Object

Auto Trait Implementations§

§

impl Freeze for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object

§

impl Sync for Object

§

impl Unpin for Object

§

impl UnwindSafe for Object

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.