Trait simd_json::prelude::Object

source ·
pub trait Object {
    type Key;
    type Element;

    // Required methods
    fn get<Q>(&self, k: &Q) -> Option<&Self::Element>
       where Self::Key: Borrow<Q> + Hash + Eq,
             Q: Hash + Eq + Ord + ?Sized;
    fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut Self::Element>
       where Self::Key: Borrow<Q> + Hash + Eq,
             Q: Hash + Eq + Ord + ?Sized;
    fn insert<K, V>(&mut self, k: K, v: V) -> Option<Self::Element>
       where K: Into<Self::Key>,
             V: Into<Self::Element>,
             Self::Key: Hash + Eq;
    fn remove<Q>(&mut self, k: &Q) -> Option<Self::Element>
       where Self::Key: Borrow<Q>,
             Q: Hash + Eq + Ord + ?Sized;
    fn iter<'i>(
        &'i self
    ) -> Box<dyn Iterator<Item = (&'i Self::Key, &'i Self::Element)> + 'i, Global>;
    fn keys<'i>(
        &'i self
    ) -> Box<dyn Iterator<Item = &'i Self::Key> + 'i, Global>;
    fn values<'i>(
        &'i self
    ) -> Box<dyn Iterator<Item = &'i Self::Element> + 'i, Global>;
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Prelude to include needed traits A JSON Object

Required Associated Types§

source

type Key

The key in the objects

source

type Element

The values in the object

Required Methods§

source

fn get<Q>(&self, k: &Q) -> Option<&Self::Element>where Self::Key: Borrow<Q> + Hash + Eq, Q: Hash + Eq + Ord + ?Sized,

Gets a ref to a value based on a key, returns None if the current Value isn’t an Object or doesn’t contain the key it was asked for.

source

fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut Self::Element>where Self::Key: Borrow<Q> + Hash + Eq, Q: Hash + Eq + Ord + ?Sized,

Gets the value of a key as a mutable reference.

source

fn insert<K, V>(&mut self, k: K, v: V) -> Option<Self::Element>where K: Into<Self::Key>, V: Into<Self::Element>, Self::Key: Hash + Eq,

Inserts a value

source

fn remove<Q>(&mut self, k: &Q) -> Option<Self::Element>where Self::Key: Borrow<Q>, Q: Hash + Eq + Ord + ?Sized,

Removes a value from the object

source

fn iter<'i>( &'i self ) -> Box<dyn Iterator<Item = (&'i Self::Key, &'i Self::Element)> + 'i, Global>

Iterates over the key value paris

source

fn keys<'i>(&'i self) -> Box<dyn Iterator<Item = &'i Self::Key> + 'i, Global>

Iterates over the keys

source

fn values<'i>( &'i self ) -> Box<dyn Iterator<Item = &'i Self::Element> + 'i, Global>

Iterates over the values

source

fn len(&self) -> usize

Number of key/value pairs

Provided Methods§

source

fn is_empty(&self) -> bool

Returns if the array is empty

Implementations on Foreign Types§

source§

impl<MapK, MapE, S> Object for HashMap<MapK, MapE, S>where S: BuildHasher, MapK: Hash + Eq,

§

type Key = MapK

§

type Element = MapE

source§

fn get<Q>(&self, k: &Q) -> Option<&<HashMap<MapK, MapE, S> as Object>::Element>where <HashMap<MapK, MapE, S> as Object>::Key: Borrow<Q> + Hash + Eq, Q: Hash + Eq + Ord + ?Sized,

source§

fn get_mut<Q>( &mut self, k: &Q ) -> Option<&mut <HashMap<MapK, MapE, S> as Object>::Element>where <HashMap<MapK, MapE, S> as Object>::Key: Borrow<Q> + Hash + Eq, Q: Hash + Eq + Ord + ?Sized,

source§

fn insert<K, V>( &mut self, k: K, v: V ) -> Option<<HashMap<MapK, MapE, S> as Object>::Element>where K: Into<<HashMap<MapK, MapE, S> as Object>::Key>, V: Into<<HashMap<MapK, MapE, S> as Object>::Element>, <HashMap<MapK, MapE, S> as Object>::Key: Hash + Eq,

source§

fn remove<Q>( &mut self, k: &Q ) -> Option<<HashMap<MapK, MapE, S> as Object>::Element>where <HashMap<MapK, MapE, S> as Object>::Key: Borrow<Q> + Hash + Eq, Q: Hash + Eq + Ord + ?Sized,

source§

fn iter<'i>( &'i self ) -> Box<dyn Iterator<Item = (&'i <HashMap<MapK, MapE, S> as Object>::Key, &'i <HashMap<MapK, MapE, S> as Object>::Element)> + 'i, Global>

source§

fn keys<'i>( &'i self ) -> Box<dyn Iterator<Item = &'i <HashMap<MapK, MapE, S> as Object>::Key> + 'i, Global>

source§

fn values<'i>( &'i self ) -> Box<dyn Iterator<Item = &'i <HashMap<MapK, MapE, S> as Object>::Element> + 'i, Global>

source§

fn len(&self) -> usize

source§

impl<MapK, MapE, S> Object for SizedHashMap<MapK, MapE, S, 32>where MapK: Hash + Eq, S: BuildHasher + Default,

§

type Key = MapK

§

type Element = MapE

source§

fn get<Q>( &self, k: &Q ) -> Option<&<SizedHashMap<MapK, MapE, S, 32> as Object>::Element>where <SizedHashMap<MapK, MapE, S, 32> as Object>::Key: Borrow<Q> + Hash + Eq, Q: Hash + Eq + Ord + ?Sized,

source§

fn get_mut<Q>( &mut self, k: &Q ) -> Option<&mut <SizedHashMap<MapK, MapE, S, 32> as Object>::Element>where <SizedHashMap<MapK, MapE, S, 32> as Object>::Key: Borrow<Q> + Hash + Eq, Q: Hash + Eq + Ord + ?Sized,

source§

fn insert<K, V>( &mut self, k: K, v: V ) -> Option<<SizedHashMap<MapK, MapE, S, 32> as Object>::Element>where K: Into<<SizedHashMap<MapK, MapE, S, 32> as Object>::Key>, V: Into<<SizedHashMap<MapK, MapE, S, 32> as Object>::Element>, <SizedHashMap<MapK, MapE, S, 32> as Object>::Key: Hash + Eq,

source§

fn remove<Q>( &mut self, k: &Q ) -> Option<<SizedHashMap<MapK, MapE, S, 32> as Object>::Element>where <SizedHashMap<MapK, MapE, S, 32> as Object>::Key: Borrow<Q> + Hash + Eq, Q: Hash + Eq + Ord + ?Sized,

source§

fn iter<'i>( &'i self ) -> Box<dyn Iterator<Item = (&'i <SizedHashMap<MapK, MapE, S, 32> as Object>::Key, &'i <SizedHashMap<MapK, MapE, S, 32> as Object>::Element)> + 'i, Global>

source§

fn keys<'i>( &'i self ) -> Box<dyn Iterator<Item = &'i <SizedHashMap<MapK, MapE, S, 32> as Object>::Key> + 'i, Global>

source§

fn values<'i>( &'i self ) -> Box<dyn Iterator<Item = &'i <SizedHashMap<MapK, MapE, S, 32> as Object>::Element> + 'i, Global>

source§

fn len(&self) -> usize

Implementors§