relay_log::protocol::value

Struct Map

source
pub struct Map<K, V> { /* private fields */ }
Expand description

Represents a JSON key/value type.

Implementations§

source§

impl Map<String, Value>

source

pub fn new() -> Map<String, Value>

Makes a new empty Map.

source

pub fn with_capacity(capacity: usize) -> Map<String, Value>

Makes a new empty Map with the given initial capacity.

source

pub fn clear(&mut self)

Clears the map, removing all values.

source

pub fn get<Q>(&self, key: &Q) -> Option<&Value>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.

source

pub fn contains_key<Q>(&self, key: &Q) -> bool
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Returns true if the map contains a value for the specified key.

The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.

source

pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Returns a mutable reference to the value corresponding to the key.

The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.

source

pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&String, &Value)>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Returns the key-value pair matching the given key.

The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.

source

pub fn insert(&mut self, k: String, v: Value) -> Option<Value>

Inserts a key-value pair into the map.

If the map did not have this key present, None is returned.

If the map did have this key present, the value is updated, and the old value is returned.

source

pub fn remove<Q>(&mut self, key: &Q) -> Option<Value>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Removes a key from the map, returning the value at the key if the key was previously in the map.

The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.

If serde_json’s “preserve_order” is enabled, .remove(key) is equivalent to [.swap_remove(key)][Self::swap_remove], replacing this entry’s position with the last element. If you need to preserve the relative order of the keys in the map, use [.shift_remove(key)][Self::shift_remove] instead.

source

pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Removes a key from the map, returning the stored key and value if the key was previously in the map.

The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.

If serde_json’s “preserve_order” is enabled, .remove_entry(key) is equivalent to [.swap_remove_entry(key)][Self::swap_remove_entry], replacing this entry’s position with the last element. If you need to preserve the relative order of the keys in the map, use [.shift_remove_entry(key)][Self::shift_remove_entry] instead.

source

pub fn append(&mut self, other: &mut Map<String, Value>)

Moves all elements from other into self, leaving other empty.

source

pub fn entry<S>(&mut self, key: S) -> Entry<'_>
where S: Into<String>,

Gets the given key’s corresponding entry in the map for in-place manipulation.

source

pub fn len(&self) -> usize

Returns the number of elements in the map.

source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

source

pub fn iter(&self) -> Iter<'_>

Gets an iterator over the entries of the map.

source

pub fn iter_mut(&mut self) -> IterMut<'_>

Gets a mutable iterator over the entries of the map.

source

pub fn keys(&self) -> Keys<'_>

Gets an iterator over the keys of the map.

source

pub fn values(&self) -> Values<'_>

Gets an iterator over the values of the map.

source

pub fn values_mut(&mut self) -> ValuesMut<'_>

Gets an iterator over mutable values of the map.

source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&String, &mut Value) -> bool,

Retains only the elements specified by the predicate.

In other words, remove all pairs (k, v) such that f(&k, &mut v) returns false.

source

pub fn sort_keys(&mut self)

Sorts this map’s entries in-place using str’s usual ordering.

If serde_json’s “preserve_order” feature is not enabled, this method does no work because all JSON maps are always kept in a sorted state.

If serde_json’s “preserve_order” feature is enabled, this method destroys the original source order or insertion order of this map in favor of an alphanumerical order that matches how a BTreeMap with the same contents would be ordered. This takes O(n log n + c) time where n is the length of the map and c is the capacity.

Other maps nested within the values of this map are not sorted. If you need the entire data structure to be sorted at all levels, you must also call map.values_mut().for_each(Value::sort_all_objects).

Trait Implementations§

source§

impl Clone for Map<String, Value>

source§

fn clone(&self) -> Map<String, Value>

Returns a copy of the value. Read more
source§

fn clone_from(&mut self, source: &Map<String, Value>)

Performs copy-assignment from source. Read more
source§

impl Debug for Map<String, Value>

source§

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

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

impl Default for Map<String, Value>

source§

fn default() -> Map<String, Value>

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Map<String, Value>

source§

fn deserialize<D>( deserializer: D, ) -> Result<Map<String, Value>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserializer<'de> for &'de Map<String, Value>

source§

type Error = Error

The error type that can be returned if some error occurs during deserialization.
source§

fn deserialize_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
source§

fn deserialize_enum<V>( self, _name: &'static str, _variants: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
source§

fn deserialize_ignored_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
source§

fn deserialize_bool<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
source§

fn deserialize_i8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
source§

fn deserialize_i16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
source§

fn deserialize_i32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
source§

fn deserialize_i64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
source§

fn deserialize_i128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
source§

fn deserialize_u8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
source§

fn deserialize_u16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
source§

fn deserialize_u32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
source§

fn deserialize_u64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
source§

fn deserialize_u128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
source§

fn deserialize_f32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
source§

fn deserialize_f64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
source§

fn deserialize_char<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
source§

fn deserialize_str<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_string<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_bytes<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_byte_buf<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_option<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
source§

fn deserialize_unit<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
source§

fn deserialize_unit_struct<V>( self, name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
source§

fn deserialize_newtype_struct<V>( self, name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
source§

fn deserialize_seq<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
source§

fn deserialize_tuple<V>( self, len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
source§

fn deserialize_tuple_struct<V>( self, name: &'static str, len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
source§

fn deserialize_map<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
source§

fn deserialize_struct<V>( self, name: &'static str, fields: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
source§

fn deserialize_identifier<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
source§

impl<'de> Deserializer<'de> for Map<String, Value>

source§

type Error = Error

The error type that can be returned if some error occurs during deserialization.
source§

fn deserialize_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
source§

fn deserialize_enum<V>( self, _name: &'static str, _variants: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
source§

fn deserialize_ignored_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
source§

fn deserialize_bool<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
source§

fn deserialize_i8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
source§

fn deserialize_i16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
source§

fn deserialize_i32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
source§

fn deserialize_i64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
source§

fn deserialize_i128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
source§

fn deserialize_u8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
source§

fn deserialize_u16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
source§

fn deserialize_u32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
source§

fn deserialize_u64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
source§

fn deserialize_u128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
source§

fn deserialize_f32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
source§

fn deserialize_f64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
source§

fn deserialize_char<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
source§

fn deserialize_str<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_string<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_bytes<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_byte_buf<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_option<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
source§

fn deserialize_unit<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
source§

fn deserialize_unit_struct<V>( self, name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
source§

fn deserialize_newtype_struct<V>( self, name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
source§

fn deserialize_seq<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
source§

fn deserialize_tuple<V>( self, len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
source§

fn deserialize_tuple_struct<V>( self, name: &'static str, len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
source§

fn deserialize_map<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
source§

fn deserialize_struct<V>( self, name: &'static str, fields: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
source§

fn deserialize_identifier<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Map<String, Value> as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
source§

impl Extend<(String, Value)> for Map<String, Value>

source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = (String, Value)>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl From<Map<String, Value>> for Value

source§

fn from(f: Map<String, Value>) -> Value

Convert map (with string keys) to Value::Object.

§Examples
use serde_json::{Map, Value};

let mut m = Map::new();
m.insert("Lorem".to_owned(), "ipsum".into());
let x: Value = m.into();
source§

impl FromIterator<(String, Value)> for Map<String, Value>

source§

fn from_iter<T>(iter: T) -> Map<String, Value>
where T: IntoIterator<Item = (String, Value)>,

Creates a value from an iterator. Read more
source§

impl Hash for Map<String, Value>

source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<Q> Index<&Q> for Map<String, Value>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Access an element of this map. Panics if the given key is not present in the map.

match val {
    Value::String(s) => Some(s.as_str()),
    Value::Array(arr) => arr[0].as_str(),
    Value::Object(map) => map["type"].as_str(),
    _ => None,
}
source§

type Output = Value

The returned type after indexing.
source§

fn index(&self, index: &Q) -> &Value

Performs the indexing (container[index]) operation. Read more
source§

impl<Q> IndexMut<&Q> for Map<String, Value>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Mutably access an element of this map. Panics if the given key is not present in the map.

map["key"] = json!("value");
source§

fn index_mut(&mut self, index: &Q) -> &mut Value

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<'de> IntoDeserializer<'de, Error> for &'de Map<String, Value>

source§

type Deserializer = &'de Map<String, Value>

The type of the deserializer being converted into.
source§

fn into_deserializer( self, ) -> <&'de Map<String, Value> as IntoDeserializer<'de, Error>>::Deserializer

Convert this value into a deserializer.
source§

impl<'de> IntoDeserializer<'de, Error> for Map<String, Value>

source§

type Deserializer = Map<String, Value>

The type of the deserializer being converted into.
source§

fn into_deserializer( self, ) -> <Map<String, Value> as IntoDeserializer<'de, Error>>::Deserializer

Convert this value into a deserializer.
source§

impl<'a> IntoIterator for &'a Map<String, Value>

source§

type Item = (&'a String, &'a Value)

The type of the elements being iterated over.
source§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <&'a Map<String, Value> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a> IntoIterator for &'a mut Map<String, Value>

source§

type Item = (&'a String, &'a mut Value)

The type of the elements being iterated over.
source§

type IntoIter = IterMut<'a>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <&'a mut Map<String, Value> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl IntoIterator for Map<String, Value>

source§

type Item = (String, Value)

The type of the elements being iterated over.
source§

type IntoIter = IntoIter

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <Map<String, Value> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq for Map<String, Value>

source§

fn eq(&self, other: &Map<String, Value>) -> bool

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

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

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

impl Serialize for Map<String, Value>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Map<String, Value>

Auto Trait Implementations§

§

impl<K, V> Freeze for Map<K, V>

§

impl<K, V> RefUnwindSafe for Map<K, V>

§

impl<K, V> Send for Map<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for Map<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for Map<K, V>

§

impl<K, V> UnwindSafe for Map<K, V>

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§

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

source§

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

source§

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

source§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T