> This page is for NeMo Relay, version dev.
> For other versions, use one of these documentation indexes:
> - Latest (v0.11.2) (default): https://docs.nvidia.com/nemo/relay/latest/llms.txt
> - dev: https://docs.nvidia.com/nemo/relay/dev/llms.txt
> - v0.11.2: https://docs.nvidia.com/nemo/relay/v0.11.2/llms.txt
> - v0.10.4: https://docs.nvidia.com/nemo/relay/v0.10.4/llms.txt
> - v0.9.4: https://docs.nvidia.com/nemo/relay/v0.9.4/llms.txt
> - v0.8.4: https://docs.nvidia.com/nemo/relay/v0.8.4/llms.txt
> - v0.7.3: https://docs.nvidia.com/nemo/relay/v0.7.3/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/relay/llms.txt.

# Struct Map

> Represents a JSON key/value type.

Generated from `cargo doc --no-deps -p nemo-relay-builtins -p nemo-relay-diagnostics -p nemo-relay-logging -p nemo-relay-plugin-host -p nemo-relay-codecs -p nemo-relay -p nemo-relay-runtime -p nemo-relay-model-pricing -p nemo-relay-resource-metrics -p nemo-relay-observability -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker`.

```rust
pub struct Map<K, V> { /* private fields */ }
```

Represents a JSON key/value type.

## Implementations

### `impl Map<String, Value>`

<pre />

#### `new`

<pre />

Makes a new empty Map.

#### `with_capacity`

<pre />

Makes a new empty Map with the given initial capacity.

#### `clear`

<pre />

Clears the map, removing all values.

#### `get`

<pre />

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.

#### `contains_key`

<pre />

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.

#### `get_mut`

<pre />

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.

#### `get_key_value`

<pre />

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.

#### `insert`

<pre />

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.

#### `remove`

<pre />

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.

#### `remove_entry`

<pre />

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.

#### `append`

<pre />

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

#### `entry`

<pre />

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

#### `len`

<pre />

Returns the number of elements in the map.

#### `is_empty`

<pre />

Returns true if the map contains no elements.

#### `iter`

<pre />

Gets an iterator over the entries of the map.

#### `iter_mut`

<pre />

Gets a mutable iterator over the entries of the map.

#### `keys`

<pre />

Gets an iterator over the keys of the map.

#### `values`

<pre />

Gets an iterator over the values of the map.

#### `values_mut`

<pre />

Gets an iterator over mutable values of the map.

#### `into_values`

<pre />

Gets an iterator over the values of the map.

#### `retain`

<pre />

Retains only the elements specified by the predicate.

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

#### `sort_keys`

<pre />

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

### `impl Clone for Map<String, Value>`

<pre />

#### `clone`

<pre />

#### `clone_from`

<pre />

### `impl Debug for Map<String, Value>`

<pre />

#### `fmt`

<pre />

### `impl Default for Map<String, Value>`

<pre />

#### `default`

<pre />

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

<pre />

#### `deserialize`

<pre />

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

<pre />

#### `Error`

<pre />

#### `deserialize_any`

<pre />

#### `deserialize_enum`

<pre />

#### `deserialize_ignored_any`

<pre />

#### `deserialize_bool`

<pre />

#### `deserialize_i8`

<pre />

#### `deserialize_i16`

<pre />

#### `deserialize_i32`

<pre />

#### `deserialize_i64`

<pre />

#### `deserialize_i128`

<pre />

#### `deserialize_u8`

<pre />

#### `deserialize_u16`

<pre />

#### `deserialize_u32`

<pre />

#### `deserialize_u64`

<pre />

#### `deserialize_u128`

<pre />

#### `deserialize_f32`

<pre />

#### `deserialize_f64`

<pre />

#### `deserialize_char`

<pre />

#### `deserialize_str`

<pre />

#### `deserialize_string`

<pre />

#### `deserialize_bytes`

<pre />

#### `deserialize_byte_buf`

<pre />

#### `deserialize_option`

<pre />

#### `deserialize_unit`

<pre />

#### `deserialize_unit_struct`

<pre />

#### `deserialize_newtype_struct`

<pre />

#### `deserialize_seq`

<pre />

#### `deserialize_tuple`

<pre />

#### `deserialize_tuple_struct`

<pre />

#### `deserialize_map`

<pre />

#### `deserialize_struct`

<pre />

#### `deserialize_identifier`

<pre />

#### `is_human_readable`

<pre />

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

<pre />

#### `Error`

<pre />

#### `deserialize_any`

<pre />

#### `deserialize_enum`

<pre />

#### `deserialize_ignored_any`

<pre />

#### `deserialize_bool`

<pre />

#### `deserialize_i8`

<pre />

#### `deserialize_i16`

<pre />

#### `deserialize_i32`

<pre />

#### `deserialize_i64`

<pre />

#### `deserialize_i128`

<pre />

#### `deserialize_u8`

<pre />

#### `deserialize_u16`

<pre />

#### `deserialize_u32`

<pre />

#### `deserialize_u64`

<pre />

#### `deserialize_u128`

<pre />

#### `deserialize_f32`

<pre />

#### `deserialize_f64`

<pre />

#### `deserialize_char`

<pre />

#### `deserialize_str`

<pre />

#### `deserialize_string`

<pre />

#### `deserialize_bytes`

<pre />

#### `deserialize_byte_buf`

<pre />

#### `deserialize_option`

<pre />

#### `deserialize_unit`

<pre />

#### `deserialize_unit_struct`

<pre />

#### `deserialize_newtype_struct`

<pre />

#### `deserialize_seq`

<pre />

#### `deserialize_tuple`

<pre />

#### `deserialize_tuple_struct`

<pre />

#### `deserialize_map`

<pre />

#### `deserialize_struct`

<pre />

#### `deserialize_identifier`

<pre />

#### `is_human_readable`

<pre />

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

<pre />

#### `extend`

<pre />

#### `extend_one`

<pre />

#### `extend_reserve`

<pre />

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

<pre />

#### `from_iter`

<pre />

### `impl FromStr for Map<String, Value>`

<pre />

#### `Err`

<pre />

#### `from_str`

<pre />

### `impl Hash for Map<String, Value>`

<pre />

#### `hash`

<pre />

#### `hash_slice`

<pre />

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

<pre />

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

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

#### `Output`

<pre />

#### `index`

<pre />

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

<pre />

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

```rust
map["key"] = json!("value");
```

#### `index_mut`

<pre />

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

<pre />

#### `Deserializer`

<pre />

#### `into_deserializer`

<pre />

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

<pre />

#### `Deserializer`

<pre />

#### `into_deserializer`

<pre />

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

<pre />

#### `Item`

<pre />

#### `IntoIter`

<pre />

#### `into_iter`

<pre />

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

<pre />

#### `Item`

<pre />

#### `IntoIter`

<pre />

#### `into_iter`

<pre />

### `impl IntoIterator for Map<String, Value>`

<pre />

#### `Item`

<pre />

#### `IntoIter`

<pre />

#### `into_iter`

<pre />

### `impl JsonSchema for Map<String, Value>`

<pre />

#### `is_referenceable`

<pre />

#### `schema_name`

<pre />

#### `schema_id`

<pre />

#### `json_schema`

<pre />

### `impl PartialEq for Map<String, Value>`

<pre />

#### `eq`

<pre />

#### `ne`

<pre />

### `impl Serialize for Map<String, Value>`

<pre />

#### `serialize`

<pre />

### `impl WireValue<JsonObject> for Map<String, Value>`

<pre />

#### `to_wire`

<pre />

#### `from_wire`

<pre />

### `impl Eq for Map<String, Value>`

<pre />