Struct plist::dictionary::Dictionary
source · pub struct Dictionary { /* private fields */ }
Expand description
Represents a plist dictionary type.
Implementations§
source§impl Dictionary
impl Dictionary
sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
Returns a reference to the value corresponding to the key.
sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if the dictionary contains a value for the specified key.
sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
Returns a mutable reference to the value corresponding to the key.
sourcepub fn insert(&mut self, k: String, v: Value) -> Option<Value>
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.
sourcepub fn remove(&mut self, key: &str) -> Option<Value>
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.
sourcepub fn retain<F>(&mut self, keep: F)
pub fn retain<F>(&mut self, keep: F)
Scan through each key-value pair in the map and keep those where the
closure keep
returns true
.
sourcepub fn sort_keys(&mut self)
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.
sourcepub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
Gets a mutable iterator over the entries of the dictionary.
sourcepub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ
Gets an iterator over mutable values of the dictionary.
Trait Implementations§
source§impl Clone for Dictionary
impl Clone for Dictionary
source§fn clone(&self) -> Dictionary
fn clone(&self) -> Dictionary
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Dictionary
impl Debug for Dictionary
source§impl Default for Dictionary
impl Default for Dictionary
source§fn default() -> Dictionary
fn default() -> Dictionary
source§impl<'de> Deserialize<'de> for Dictionary
impl<'de> Deserialize<'de> for Dictionary
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl Extend<(String, Value)> for Dictionary
impl Extend<(String, Value)> for Dictionary
source§fn extend<T>(&mut self, iter: T)
fn extend<T>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl From<Dictionary> for Value
impl From<Dictionary> for Value
source§fn from(from: Dictionary) -> Value
fn from(from: Dictionary) -> Value
source§impl<K: Into<String>, V: Into<Value>> FromIterator<(K, V)> for Dictionary
impl<K: Into<String>, V: Into<Value>> FromIterator<(K, V)> for Dictionary
source§impl<'a> Index<&'a str> for Dictionary
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,
}
source§impl<'a> IndexMut<&'a str> for Dictionary
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§impl<'a> IntoIterator for &'a Dictionary
impl<'a> IntoIterator for &'a Dictionary
source§impl<'a> IntoIterator for &'a mut Dictionary
impl<'a> IntoIterator for &'a mut Dictionary
source§impl IntoIterator for Dictionary
impl IntoIterator for Dictionary
source§impl PartialEq for Dictionary
impl PartialEq for Dictionary
source§fn eq(&self, other: &Dictionary) -> bool
fn eq(&self, other: &Dictionary) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for Dictionary
impl Serialize for Dictionary
impl StructuralPartialEq for Dictionary
Auto Trait Implementations§
impl Freeze for Dictionary
impl RefUnwindSafe for Dictionary
impl Send for Dictionary
impl Sync for Dictionary
impl Unpin for Dictionary
impl UnwindSafe for Dictionary
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)