[][src]Struct packs::Dictionary

pub struct Dictionary<T>(_);

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]

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]

impl<T: Debug> Debug for Dictionary<T>[src]

impl<T> Extract<T> for Dictionary<T>[src]

impl<T> ExtractMut<T> for Dictionary<T>[src]

impl<T> ExtractRef<T> for Dictionary<T>[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]

impl<T> StructuralPartialEq for Dictionary<T>[src]

impl<P: Unpack> Unpack for Dictionary<P>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Dictionary<T> where
    T: RefUnwindSafe

impl<T> Send for Dictionary<T> where
    T: Send

impl<T> Sync for Dictionary<T> where
    T: Sync

impl<T> Unpin for Dictionary<T> where
    T: Unpin

impl<T> UnwindSafe for Dictionary<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.