[−][src]Struct packs::Dictionary
A Dictionary
is a map of String
to Value<T>
pairs. These pairs are
also called properties
and can be seen as named values. The type parameter denotes the allowed
structures for a value.
Implementations
impl<T> Dictionary<T>
[src]
pub fn with_capacity(capacity: usize) -> Self
[src]
pub fn new() -> Self
[src]
pub fn from_inner(map: HashMap<String, Value<T>>) -> Self
[src]
pub fn into_inner(self) -> HashMap<String, Value<T>>
[src]
pub fn inner(&self) -> &HashMap<String, Value<T>>
[src]
pub fn add_property<V: Into<Value<T>>>(
&mut self,
key: &str,
value: V
) -> Option<Value<T>>
[src]
&mut self,
key: &str,
value: V
) -> Option<Value<T>>
Adds a key-value pair to the Dictionary
. Returns the original value of the property
if it was already set.
pub fn has_property(&self, key: &str) -> bool
[src]
pub fn extract_property(&mut self, key: &str) -> Option<Value<T>>
[src]
pub fn extract_property_typed<V: Extract<T>>(&mut self, key: &str) -> Option<V>
[src]
Removes the property from the dictionary and returns it. Tries to extract the value strongly typed.
Panics if it cannot cast the value to provided type.
pub fn get_property(&self, key: &str) -> Option<&Value<T>>
[src]
Retrieves a property.
pub fn get_property_typed<V: ExtractRef<T>>(&self, key: &str) -> Option<&V>
[src]
Retrieves the value of a property in a strongly typed manner.
Panics if it cannot cast the value to provided type.
// create a Dictionary with a list of values as property: let mut dict = Dictionary::with_capacity(1); let list: Vec<Value<()>> = vec!(Value::Integer(1), Value::Boolean(true)); dict.add_property("foo", list.clone()); // retrieve this list: let get_list = dict.get_property_typed("foo"); assert_eq!(Some(&list), get_list);
pub fn properties(&self) -> Iter<'_, String, Value<T>>
[src]
pub fn properties_mut(&mut self) -> IterMut<'_, String, Value<T>>
[src]
pub fn entry(&mut self, key: String) -> Entry<'_, String, Value<T>>
[src]
pub fn len(&self) -> usize
[src]
Trait Implementations
impl<T: Clone> Clone for Dictionary<T>
[src]
pub fn clone(&self) -> Dictionary<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug> Debug for Dictionary<T>
[src]
impl<T> Extract<T> for Dictionary<T>
[src]
impl<T> ExtractMut<T> for Dictionary<T>
[src]
pub fn extract_mut(from: &mut Value<T>) -> Option<&mut Self>
[src]
pub fn extract_opt_mut(from: &mut Value<T>) -> Option<Option<&mut Self>>
[src]
impl<T> ExtractRef<T> for Dictionary<T>
[src]
pub fn extract_ref(from: &Value<T>) -> Option<&Self>
[src]
pub fn extract_opt_ref(from: &Value<T>) -> Option<Option<&Self>>
[src]
impl<T> FromIterator<(String, Value<T>)> for Dictionary<T>
[src]
impl<P: Pack> Pack for Dictionary<P>
[src]
impl<T: PartialEq> PartialEq<Dictionary<T>> for Dictionary<T>
[src]
pub fn eq(&self, other: &Dictionary<T>) -> bool
[src]
pub fn ne(&self, other: &Dictionary<T>) -> bool
[src]
impl<T> StructuralPartialEq for Dictionary<T>
[src]
impl<P: Unpack> Unpack for Dictionary<P>
[src]
pub fn decode_body<T: Read>(
marker: Marker,
reader: &mut T
) -> Result<Self, DecodeError>
[src]
marker: Marker,
reader: &mut T
) -> Result<Self, DecodeError>
pub fn decode<T: Read>(reader: &mut T) -> Result<Self, DecodeError>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Dictionary<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Dictionary<T> where
T: Send,
T: Send,
impl<T> Sync for Dictionary<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Dictionary<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Dictionary<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,