Type Alias toml::Table

source ·
pub type Table = Map<String, Value>;
Expand description

Type representing a TOML table, payload of the Value::Table variant. By default it is backed by a BTreeMap, enable the preserve_order feature to use a LinkedHashMap instead.

Aliased Type§

struct Table { /* private fields */ }

Implementations§

source§

impl Table

source

pub fn try_from<T>(value: T) -> Result<Self, Error>where T: Serialize,

Convert a T into toml::Table.

This conversion can fail if T’s implementation of Serialize decides to fail, or if T contains a map with non-string keys.

source

pub fn try_into<'de, T>(self) -> Result<T, Error>where T: Deserialize<'de>,

Interpret a toml::Table as an instance of type T.

This conversion can fail if the structure of the Table does not match the structure expected by T, for example if T is a bool which can’t be mapped to a Table. It can also fail if the structure is correct but T’s implementation of Deserialize decides that something is wrong with the data, for example required struct fields are missing from the TOML map or some number is too big to fit in the expected primitive type.

source§

impl Map<String, Value>

source

pub fn new() -> Self

Makes a new empty Map.

source

pub fn with_capacity(capacity: usize) -> Self

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) -> boolwhere 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 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. The key is not updated, though; this matters for types that can be == without being identical.

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.

source

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

Retains only the elements specified by the keep predicate.

In other words, remove all pairs (k, v) for which keep(&k, &mut v) returns false.

The elements are visited in iteration order.

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.

Trait Implementations§

source§

impl Clone for Map<String, Value>

source§

fn clone(&self) -> Self

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 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() -> Self

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<Self, D::Error>where D: Deserializer<'de>,

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

impl<'de> Deserializer<'de> for Table

§

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::Value, 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::Value, 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_option<V>(self, visitor: V) -> Result<V::Value, Error>where V: Visitor<'de>,

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

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

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

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

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

fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::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::Value, Self::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::Value, Self::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::Value, Self::Error>where V: Visitor<'de>,

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

fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::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::Value, Self::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::Value, Self::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::Value, Self::Error>where V: Visitor<'de>,

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

fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::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::Value, Self::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::Value, Self::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::Value, Self::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::Value, Self::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_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>where V: Visitor<'de>,

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

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

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

fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::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::Value, Self::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_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>where V: Visitor<'de>,

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

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

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

fn deserialize_tuple_struct<V>( self, name: &'static str, len: usize, visitor: V ) -> Result<V::Value, Self::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_struct<V>( self, name: &'static str, fields: &'static [&'static str], visitor: V ) -> Result<V::Value, Self::Error>where V: Visitor<'de>,

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

fn deserialize_tuple<V>( self, len: usize, visitor: V ) -> Result<V::Value, Self::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_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::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_identifier<V>(self, visitor: V) -> Result<V::Value, Self::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 deserialize_i128<V>( self, visitor: V ) -> Result<<V as Visitor<'de>>::Value, Self::Error>where V: Visitor<'de>,

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

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

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

fn is_human_readable(&self) -> bool

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

impl Display for Table

source§

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

Formats the value using the given formatter. 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 FromIterator<(String, Value)> for Map<String, Value>

source§

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

Creates a value from an iterator. Read more
source§

impl FromStr for Table

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<'a, Q> Index<&'a 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.

§

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<'a, Q> IndexMut<&'a 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.

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 Table

§

type Deserializer = Map<String, Value>

The type of the deserializer being converted into.
source§

fn into_deserializer(self) -> Self

Convert this value into a deserializer.
source§

impl IntoIterator for Map<String, Value>

§

type Item = (String, Value)

The type of the elements being iterated over.
§

type IntoIter = IntoIter

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

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

source§

fn eq(&self, other: &Self) -> 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 Serialize for Map<String, Value>

source§

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

Serialize this value into the given Serde serializer. Read more