pub struct Dictionary { /* private fields */ }
Expand description

Represents a plist dictionary type.

Implementations§

source§

impl Dictionary

source

pub fn new() -> Self

Makes a new empty Dictionary.

source

pub fn clear(&mut self)

Clears the dictionary, removing all values.

source

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

Returns a reference to the value corresponding to the key.

source

pub fn contains_key(&self, key: &str) -> bool

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

source

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

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

source

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

Inserts a key-value pair into the dictionary.

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

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

source

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

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

source

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

Scan through each key-value pair in the map and keep those where the closure keep returns true.

source

pub fn sort_keys(&mut self)

Sort the dictionary keys.

This uses the default ordering defined on str.

This function is useful if you are serializing to XML, and wish to ensure a consistent key order.

source

pub fn len(&self) -> usize

Returns the number of elements in the dictionary.

source

pub fn is_empty(&self) -> bool

Returns true if the dictionary contains no elements.

source

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

Gets an iterator over the entries of the dictionary.

source

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

Gets a mutable iterator over the entries of the dictionary.

source

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

Gets an iterator over the keys of the dictionary.

source

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

Gets an iterator over the values of the dictionary.

source

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

Gets an iterator over mutable values of the dictionary.

Trait Implementations§

source§

impl Clone for Dictionary

source§

fn clone(&self) -> Dictionary

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 Dictionary

source§

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

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

impl Default for Dictionary

source§

fn default() -> Dictionary

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

impl<'de> Deserialize<'de> for Dictionary

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 Extend<(String, Value)> for Dictionary

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<Dictionary> for Value

source§

fn from(from: Dictionary) -> Value

Converts to this type from the input type.
source§

impl<K: Into<String>, V: Into<Value>> FromIterator<(K, V)> for Dictionary

source§

fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<'a> Index<&'a str> for Dictionary

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

match *val {
    Value::Array(ref arr) => arr[0].as_string(),
    Value::Dictionary(ref dict) => dict["type"].as_string(),
    Value::String(ref s) => Some(s.as_str()),
    _ => None,
}
§

type Output = Value

The returned type after indexing.
source§

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

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

impl<'a> IndexMut<&'a str> for Dictionary

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

dict["key"] = "value".into();
source§

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

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

impl<'a> IntoIterator for &'a Dictionary

§

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

The type of the elements being iterated over.
§

type IntoIter = Iter<'a>

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<'a> IntoIterator for &'a mut Dictionary

§

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

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a>

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 IntoIterator for Dictionary

§

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 for Dictionary

source§

fn eq(&self, other: &Dictionary) -> 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 Dictionary

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

impl StructuralPartialEq for Dictionary

Auto Trait Implementations§

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

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